Dmitry Pryanishnikov
2003-Dec-18 01:54 UTC
ftime doesn't fetch from libcompat.a using -lcompat
Hello! I've found a very unusual bug. I've tried to build a legacy program which uses ftime(), but I've got unresolved reference to `ftime'. I've created a very simple program that demonstrates a bug: #include <sys/types.h> #include <sys/timeb.h> main() { struct timeb tb; return ftime(&tb); } dmitry@test$ cc -lcompat a.c /tmp/cck3ZpNz.o: In function `main': /tmp/cck3ZpNz.o(.text+0xe): undefined reference to `ftime' dmitry@test$ cc -lcompat -static a.c /tmp/ccbGUAGZ.o: In function `main': /tmp/ccbGUAGZ.o(.text+0xe): undefined reference to `ftime' The most interesting thing here is that I can extract module ftime.o from my /usr/lib/libcompat.a and link against it: dmitry@test$ ar p /usr/lib/libcompat.a ftime.o >ftime.o dmitry@test$ cc a.c ftime.o dmitry@test$ It seems that symbol `ftime' gets somehow "undeclared" in library symbol table. Could this error be fixed? It's present in 4.8-RELEASE and 4.9-RELEASE. I haven't found anything in GNATS about this issue. Sincerely, Dmitry -- Atlantis ISP, System Administrator e-mail: dmitry@atlantis.dp.ua nic-hdl: LYNX-RIPE
On Thu, Dec 18, 2003 at 11:54:29AM +0200, Dmitry Pryanishnikov wrote:> > Hello! > > I've found a very unusual bug. I've tried to build a legacy program which > uses ftime(), but I've got unresolved reference to `ftime'. I've created a > very simple program that demonstrates a bug: > > #include <sys/types.h> > #include <sys/timeb.h> > main() > { > struct timeb tb; > return ftime(&tb); > } > > dmitry@test$ cc -lcompat a.c > /tmp/cck3ZpNz.o: In function `main': > /tmp/cck3ZpNz.o(.text+0xe): undefined reference to `ftime' > dmitry@test$ cc -lcompat -static a.c > /tmp/ccbGUAGZ.o: In function `main': > /tmp/ccbGUAGZ.o(.text+0xe): undefined reference to `ftime' > > The most interesting thing here is that I can extract module ftime.o from > my /usr/lib/libcompat.a and link against it: > > dmitry@test$ ar p /usr/lib/libcompat.a ftime.o >ftime.o > dmitry@test$ cc a.c ftime.o > dmitry@test$ > > It seems that symbol `ftime' gets somehow "undeclared" in library symbol > table. Could this error be fixed? It's present in 4.8-RELEASE and 4.9-RELEASE. > I haven't found anything in GNATS about this issue.The error lies with you, not the system. Try compiling it using 'cc a.c -lcompat' instead. The order of objectfiles/archives does matter when using static libraries. -- <Insert your favourite quote here.> Erik Trulsson ertr1013@student.uu.se