1830747 Members
2111 Online
110015 Solutions
New Discussion

ld: Unsatisfied symbols

 
Andrew Herrmann
Occasional Advisor

ld: Unsatisfied symbols

I'm using the following:

aCC: HP ANSI C++ B3910B A.03.31
ld: 92453-07 linker linker ld B.11.33 020617

I'm building a shared library. Everything seems to work properly. However, if I use the -v (verbose) option on the ld command line, I receive a warning that there are several unsatistied symbols. For example:

ld: Unsatisfied symbols:
memset (first referenced in foo.o) (code)
memcpy (first referenced in bar.o) (code)
atoi (first referenced in foo.o) (code)
toupper (first referenced in foo.o) (code)
strlen (first referenced in foo.o) (code)
_isspace (first referenced in foo.o) (code)

I'm a little confused because these are standard C functions. I've tried various library combinations (-lblah) with both aCC and ld with no success.

I've searched through the libraries in /usr/lib with nm for memset (the first reference). nm on libc.a produces the following results:

memset.o:
U __SYSTEM_ID
000000a0 T __memset20
00000180 T __memsetfp
00000000 T _memset
00000030 t endfil
00000270 t exit_fp
0000002c t filend
000001d0 t main_memset_fp
000000f0 t main_pa20
00000000 W memset
000000a0 t memset_pa20
0000024c t memset_start_fp

I'm guessing that the "W" for memset is "weak" and that's why ld is complaining.

I'd like to get a "clean" compile -- no warning messages. Is there anything I can do to fix this?

Thanks,

Andy
7 REPLIES 7
Steve Lewis
Honored Contributor

Re: ld: Unsatisfied symbols

You didnt give the actual cc and ld commands you typed.

export LD_LIBRARY_PATH=/usr/lib

To split a simple compilation into two phases do the above then type:

cc -c myprog.c
ld /opt/langtools/lib/crt0.o -o myprog myprog.o -u main -lc

Steven Gillard_2
Honored Contributor

Re: ld: Unsatisfied symbols

Since you're building a shared library, these messages can definitely be ignored because the symbols will be resolved by the loading of libc at run-time.

You might be able to get rid of them from the verbose linker output by including the +vnocompatwarnings option.

Regards,
Steve
Adam J Markiewicz
Trusted Contributor

Re: ld: Unsatisfied symbols

Hi

Yes, these are standard C functions. They are defined in libc.a (archive version) and libc.sl (shared version).

I guess these warnings will disapear if you use the libc library during linkage (I guess for creating of shared library it is not added by default, like in executable).

If you use libc.a the complete library will be added as a part of your library, so I do not recommend it. But if you use libc.sl, this library will be added to the list of libraries requeired by your library to run and the linker will be able to confirm the existance of the functions (so it should stop complaining).

I really understand the desire for 'clean' making. :)

Good luck
Adam
I do everything perfectly, except from my mistakes
Steve Lewis
Honored Contributor

Re: ld: Unsatisfied symbols

Sorry I should really say make sure your LD_LIBRARY_PATH is correct.

To make a shared library out of myprog.c I just did this:

cc -c +z myprog.c
ld -b -o myprog.sl myprog.o -lc
Andrew Herrmann
Occasional Advisor

Re: ld: Unsatisfied symbols

I'll try to answer a whole bunch of these at once.

Compile:
aCC -c +z foo.cpp -lc -o foo.o
aCC -c +z bar.cpp -lc -o bar.o

Link:
ld -v -b -o foobar.sl foo.o bar.o
--or--
ld -v -b -o foobar.sl -lc foo.o bar.o

I've tried setting LD_LIBRARY_PATH - no change
I've tried +vnocompatwarnings - no change

if I use the second link option above (explicitly stating the library, I still get the unsatisfied symbols, but I also get a section called "unsatisfied shared library symbols"

Steve -- Just for laughs, add a -v to your ld line and see if you receive the same unsatisfied symbols message. You may want to use one of the functions that I listed above.
Steve Lewis
Honored Contributor

Re: ld: Unsatisfied symbols

Andy,

I accidentally went into Linux mode with the environment variable, on HP-UX it is LPATH, not LD_LIBRARY_PATH.

As for your suggestion, this is what I get:
$ rm t2.sl
$ ld -v -b -o t2.sl t2.o -u main -lc
ld -l:libbwiz.sl +vnocompatwarnings +k -v -b -o t2.sl t2.o -lc
LPATH is : /usr/lib:/opt/langtools/lib
Searching library /usr/lib/libbwiz.sl:
Loading t2.o:
Searching library /usr/lib/libdld.2:
Searching library /usr/lib/libc.sl:
Searching library /usr/lib/milli.a:

$ ll t2.sl
-rwxrwxr-x 1 dba dev 20480 Apr 17 15:59 t2.sl

The libbwiz you can ignore since it is a 3rd party library we use.
Without the -v I get no output at all.

ranganath ramachandra
Esteemed Contributor

Re: ld: Unsatisfied symbols

as pointed out earlier, these warnings can safely be ignored.

but what are you trying to achieve with the -v option of linker ?
 
--
ranga
hp-ux 11i v3[i work for hpe]

Accept or Kudo