Quick Fix to the Linker Error - ld: fatal: library -lgcc_s: not found

Symptom(s):

When building some of the open source applications like MySQL Cluster Carrier Grade Edition with the GCC compiler, the linking step may fail with the fatal error message library -lgcc_s: not found despite the fact that the gcc_s library is available on the system and is in the linker search path -- for example, LD_LIBRARY_PATH on Solaris.

Quick Fix / Workaround:

  1. Add the absolute path to the gcc_s library on the link line, OR

  2. (Recommended) If the library's filename has any major and minor version numbers appended to it, simply create a soft link to the library in the same location without the major and minor version numbers in the target filename.

eg.,

On a Solaris 10 system, by default, the gcc_s library might be available under /usr/sfw/lib (32-bit SPARC and x86 copy), /usr/sfw/lib/sparcv9 (64-bit SPARC copy) and /usr/sfw/lib/amd64 (64-bit x64 copy). If all you can find is the gcc_s library with the version number(s) in the filename like libgcc_s.so.1, simply run the command 'ln -s libgcc_s.so.1 libgcc_s.so' in the same directory where you found the libgcc_s.so.1.

Note:

Probably this particular error message may show up on any OS platform with any compiler, and the workaround mentioned in this post may work on all those failed cases. I cannot guarantee that, but I know for sure that it works on Solaris (both SPARC and x86/x64 versions).

Comments:

Hey. Just wanted to throw out a quick "thanks." Solved the error that I got when trying to first use g++ to compile a program. "/usr/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status"

Posted by Ben on June 03, 2010 at 08:36 AM PDT #

Thanks!

Posted by Lars on August 31, 2010 at 09:58 PM PDT #

Thanks! It helped me solve the error:
ld: fatal: library -lCstd: not found
ld: fatal: library -lCrun: not found
There were versions: libCrun.so.1 libCstd.so.1. creating a soft link for libCrun.so and libCstd.so works.

Posted by guest on July 20, 2011 at 10:07 PM PDT #

Very useful solution.
I just did (in my suse 10.3):

locate libgcc_s.so
and got: /usr/lib/gcc/i586-suse-linux/4.2.1/libgcc_s.so

then I did a soft link in:

cd /usr/lib/gcc-lib/i586-suse-linux/3.3.5
sudo ln -s /usr/lib/gcc/i586-suse-linux/4.2.1/libgcc_s.so libgcc_s.so

and -lgcc_s missing lib went away (FIXED)

So, compilation is find and my fortran program is doing was
is suppose to do.

Hec

Posted by guest on October 15, 2011 at 05:29 AM PDT #

Very useful solution.
I just did (in my suse 10.3):

locate libgcc_s.so
and got: /usr/lib/gcc/i586-suse-linux/4.2.1/libgcc_s.so

then I did a soft link in:

cd /usr/lib/gcc-lib/i586-suse-linux/3.3.5
sudo ln -s /usr/lib/gcc/i586-suse-linux/4.2.1/libgcc_s.so libgcc_s.so

and -lgcc_s missing lib went away (FIXED)

So, compilation is fine and my fortran program is doing was
it is suppose to do.

Hec

Posted by guest on October 15, 2011 at 05:33 AM PDT #

Looks like the duplicate symbol may be an issue with another lib and in that case, the -force_load flag may be the solution you are looking for.

Posted by kitchen cabinets online on May 26, 2012 at 04:45 AM PDT #

I meet the same question when i compile mysql source code, I fix it throug drop the "-static" option.

g++ -O3 -fno-implicit-templates -fno-exceptions -fno-rtti -rdynamic -o mysqld sql_lex.o sql_handler.o sql_partition.o item.o item_sum.o item_buff.o item_func.o item_cmpfunc.o item_strfunc.o item_timefunc.o thr_malloc.o item_create.o item_subselect.o item_row.o item_geofunc.o item_xmlfunc.o field.o strfunc.o key.o sql_class.o sql_list.o net_serv.o protocol.o sql_state.o lock.o my_lock.o sql_string.o sql_manager.o sql_map.o mysqld.o password.o hash_filo.o hostname.o sql_connect.o scheduler.o sql_parse.o set_var.o sql_yacc.o sql_base.o table.o sql_select.o sql_insert.o sql_profile.o sql_prepare.o sql_error.o sql_locale.o sql_update.o sql_delete.o uniques.o sql_do.o procedure.o sql_test.o log.o init.o derror.o sql_acl.o unireg.o des_key_file.o log_event.o rpl_record.o log_event_old.o rpl_record_old.o discover.o time.o opt_range.o opt_sum.o records.o filesort.o handler.o ha_partition.o debug_sync.o signal_handler.o sql_db.o sql_table.o sql_rename.o sql_crypt.o sql_load.o mf_iocache.o field_conv.o sql_show.o sql_udf.o sql_analyse.o sql_cache.o slave.o sql_repl.o rpl_filter.o rpl_tblmap.o rpl_utility.o rpl_injector.o rpl_rli.o rpl_mi.o rpl_reporting.o sql_union.o sql_derived.o sql_client.o repl_failsafe.o sql_olap.o sql_view.o gstream.o spatial.o sql_help.o sql_cursor.o tztime.o my_decimal.o sp_head.o sp_pcontext.o sp_rcontext.o sp.o sp_cache.o parse_file.o sql_trigger.o event_scheduler.o event_data_objects.o event_queue.o event_db_repository.o events.o sql_plugin.o sql_binlog.o sql_builtin.o sql_tablespace.o partition_info.o sql_servers.o event_parse_data.o mini_client_errors.o pack.o client.o my_time.o my_user.o -static ./.libs/libndb.a -L/usr/lib -lpthread -lpthread -lpthread -lpthread /usr/lib/libstdc++.a -lm -lgcc_s -lc -lgcc_s -lm -lgcc_s -lc -lgcc_s ../storage/csv/libcsv.a ../storage/heap/libheap.a ../storage/myisam/libmyisam.a ../storage/myisammrg/libmyisammrg.a ../vio/libvio.a ../mysys/libmysys.a ../dbug/libdbug.a ../regex/libregex.a ../strings/libmystrings.a -lz -lpthread -lcrypt -lnsl -lm -lpthread
/usr/lib/gcc/i586-suse-linux/4.1.0/../../../../i586-suse-linux/bin/ld: cannot find -lgcc_s
==> just remove "-static" is ok.

Posted by guest on August 30, 2012 at 07:02 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Benchmark announcements, HOW-TOs, Tips and Troubleshooting

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today