This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
-llibrary's position in ld cause with -static
- From: Zhang Le <ejoy at xinhuanet dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 9 Sep 2003 22:02:45 +0800
- Subject: -llibrary's position in ld cause with -static
Hello,
I'm not quite sure whether this is a bug in ld or gcc or just wrong
usage. I tried following command on a FreeBSD 4.8 with gcc3.2:
g++ -static -o src/maxent src/maxent.o src/maxent_cmdline.o -Lsrc
-lgnugetopt -lg2c -lmaxent
where libmaxent is a C++ lib (with some fortran module linked in it)
and g2c is a C lib comes with g77 lbfgs.os is a fortran module in
libmaxent.a.
g++ fails to find some function entries in libg2c:
src/libmaxent.a(lbfgs.os): In function `lbfgs_':
lbfgs.os(.text+0x76): undefined reference to `s_wsfe'
lbfgs.os(.text+0x7b): undefined reference to `e_wsfe'
lbfgs.os(.text+0x6c7): undefined reference to `s_wsfe'
lbfgs.os(.text+0x6db): undefined reference to `do_fio'
...
But when I switched the positions of -lg2c and -lmaxent:
g++ -static -o src/maxent src/maxent.o src/maxent_cmdline.o -Lsrc
-lgnugetopt -lmaxent -lg2c
It works.
I also observed when linking without -static, both version work fine.
Could you give me a explanation of this behavior? Or I just find a
bug?