Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7957 Discussions

RH9 and static linkage with icc 7.1

nicolas_bock
Beginner
276 Views
I am trying to statically link a program on a RH9 system with the 7.1 icc compiler. From this forum I found out that I need to copy an older version of glibc somewhere. I did as suggested and got glibc-2.2.93-5 from RH8 and installed

/opt/intel/old_libs/lib/libc-2.2.93.so
/opt/intel/old_libs/lib/libpthread.so

and changed

/opt/intel/compiler70/ia32/bin/icc.cfg

to include the libraries. I can compile programs now and they run fine. In order to statically link my program I also installed

/opt/intel/old_libs/usr/lib/libc_nonshared.a
/opt/intel/old_libs/usr/lib/libc_stubs.a
/opt/intel/old_libs/usr/lib/libpthread.a
/opt/intel/old_libs/usr/lib/libc-2.2.93.a
/opt/intel/old_libs/usr/lib/libc-2.2.93.so

included -L/opt/intel/old_libs/usr/lib in icc.cfg and changed the above libc-2.2.93.so to

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
GROUP ( /opt/intel/old_libs/lib/libc2.2.93.so /opt/intel/old_libs/usr/lib/libc_nonshared.a )

I still can't statically link my program though. I get all sorts of errors along the lines of:

/usr/lib/libc.a(dl-libc.o)(.text+0xb4): In function `__libc_dlclose':
: multiple definition of `__libc_dlclose'
/opt/intel/old_libs/usr/lib/libc-2.2.93.a(dl-libc.o)(.text+0xac): first defined here

Why would the linker even try to look for /usr/lib/libc.a? I must confess that I really don't know what I am doing here, so I might be doing something really stupid. Could someone please hint me in the right direction?

Thanks a lot,

nick
0 Kudos
1 Reply
DAVID_M_Intel2
Employee
276 Views
There are a couple of things you can try:

Call the copied libc.a libc.a and use the -L option to specify the path to it. This should cause the old one to be picked up.

Or you can use the -nodefaultlibs option and specify all the libraries yourself. If you put "-#" on the end of your command line the compiler will print the linker command that would be sent to the linker so you can use that as a starting spot.

Note that we do not recommend copying libc's between versions of Linux since the libc is intimately associated with the system files on a given version of Linux.

We are currently working on RHL9 support. Static linking in particular has caused quite a bit of work.
0 Kudos
Reply