01-23-04 10:36 PM
Okay, so I began with a simple problem:
$ g++ -o client client.o stun.o udp.o
Undefined first referenced
symbol in file
HMAC stun.o
EVP_sha1 stun.o
recvfrom udp.o
ld: fatal: Symbol referencing errors. No output written to client
collect2: ld returned 1 exit status
Now, recognizing the 3 undefined symbols, I said:
$ g++ -L/lib/openssl -lcrypto -lssl -lxnet -o client client.o stun.o
udp.o
Undefined first referenced
symbol in file
EVP_sha1 stun.o
HMAC stun.o
ld: fatal: Symbol referencing errors. No output written to client
collect2: ld returned 1 exit status
Note that the "recvfrom" error has vanished. But the 2 others remain.
And now:
$ g++ -L/lib/openssl -lxnet -o client client.o stun.o udp.o -lcrypto
-lssl
$ ### it works !! ###
I had asked a similar question (ref. openssl) on this group some time
ago, and the net of the resulting discussion was that I shouldn't have
specified linker libraries before the object files. So, I ask 3 new
questions:
1. What should come first in cases like this? Link lib options like
-llib or the object files?
2. Does the rule apply to all libraries or just specific ones, e.g.
ones that were (or were not) created using gcc
3. Why does -lxnet work before the objs but -lcrypto -lssl work only
when specified after the objs
TIA,
John Galt
P.S. for what it's worth, all this happened on Solaris 9 with gcc 3.3
[ Post a follow-up to this message ]
|