views:

287

answers:

5

I'm trying to link my library xxx to a library yyy. I want to link statically so that I don't need to package yyy along with xxx when I deliver xxx. I have two versions of yyy provided by a third-party: libyyy.so and libyyyln.a. So here I go and link with -lyyyln.

I do not get any error message when I link. The dependency on yyyln does not show up when I do "ldd libxxx.so". But "ldd -r libxxx.so" shows that the symbols from yyy are not resolved. "nm libxxx.so" shows that these symbols from yyy are UNDEF.

What am I missing then?

Edit1: I managed to get it to work eventually with "-l /fullpath/libyyyln.a"

A: 

I assume you are using gcc. By default, gcc will use shared libraries (.so) if it can, so you must force it to statically link with the option -static.

Edit: Sorry, I thought sunstudio was the name of the library you are trying to link, I forgot that Sun Studio includes a compiler. There must be a similar option for sun studio, though.

Borbus
A: 

See if this helps: http://fortran-2000.com/ArnaudRecipes/sharedlib.html

Martin York
+2  A: 

You want to put -Bstatic in front of the libs you want static link with. Dig around here for more info.

Nikolai N Fetissov
A: 

You could have asked this question on the Sun Studio forum and gotten answers directly from the Sun Studio compiler team

Sun Studio Forums (for C, C++, Fortran, and tools)

A: 

I managed to get it to work eventually with "-l /fullpath/libyyyln.a"

I played around with -Bstatic and -Bdynamic without success. The solution was really as simple as what is written above. I should have thought of it earlier.

Mathieu JVL