0

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"

Mathieu JVL
  • 345
  • 2
  • 8

5 Answers5

3

You want to put -Bstatic in front of the libs you want static link with. Dig around the Solaris Linker and Libraries Guide for more info.

alanc
  • 4,102
  • 21
  • 24
Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171
1

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)

alanc
  • 4,102
  • 21
  • 24
0

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
  • 593
  • 4
  • 10
0

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

Martin York
  • 257,169
  • 86
  • 333
  • 562
0

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
  • 345
  • 2
  • 8