Linking problem

Linking problem

Post by Spiro Philopoulo » Thu, 25 Oct 2001 13:28:38



Hi. I'm trying to compile a program and it fails in the linking phase.
The compile lines I use are:

g++ -g -O2 -D_REENTRANT -D_GNU_SOURCE -D_THREAD_DAFE -c
novraSG50_trap_app.cpp
g++ -L/usr/local/lib -ls50MgmtStatus -lccxx -lccstd -lccio -lpthread
-ldl -lz -ls50MgmtStatus  -lccstd -lccxx -lccio -ldl -lz -lpthread
novraSG50_trap_app.o -o sg50trapapp

I get 'undefined reference' errors in the linking phase for functions,
objects etc. defined in the static library libs50MgmtStatus.a which I
link. I'm quite confident that the linking order is correct (that's why
I also link the libraries twice just in case) and the libraries are fine
(have been used before) and the lib path is specified. Does anybody have
an idea what the error might be? Any info/help would be greatly
appreciated. Thanks.

The linking output is:

novraSG50_trap_app.o: In function
`waitUntilNewStatusPacketReceived(unsigned&, S50MgmtStatus)':
/root/trap_apps_dir/novraSG50_trap_app.cpp:246: undefined reference to
`S50MgmtStatus::getCurrPktCount()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:264: undefined reference to
`S50MgmtStatus::getCurrPktCount()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:267: undefined reference to
`S50MgmtStatus::~S50MgmtStatus()'/root/trap_apps_dir/novraSG50_trap_app.cpp:255:
undefined reference to
`S50MgmtStatus::~S50MgmtStatus()'novraSG50_trap_app.o: In function
`waitOnFirstStatusPacketRequest(unsigned&, S50MgmtStatus)':
/root/trap_apps_dir/novraSG50_trap_app.cpp:287: undefined reference to
`S50MgmtStatus::getCurrPktCount()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:297: undefined reference to
`S50MgmtStatus::getCurrPktCount()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:297: undefined reference to
`S50MgmtStatus::~S50MgmtStatus()'/root/trap_apps_dir/novraSG50_trap_app.cpp:292:
undefined reference to
`S50MgmtStatus::~S50MgmtStatus()'novraSG50_trap_app.o: In function
`dataLockLossNotification_func(void*)':
/root/trap_apps_dir/novraSG50_trap_app.cpp:394: undefined reference to
`S50MgmtStatus::S50MgmtStatus(unsigned short, unsigned)'
/root/trap_apps_dir/novraSG50_trap_app.cpp:395: undefined reference to
`S50MgmtStatus::start()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:452: undefined reference to
`S50MgmtStatus::isDataLocked()'
/root/trap_apps_dir/novraSG50_trap_app.cpp:468: undefined reference to
`S50MgmtStatus::~S50MgmtStatus()'collect2: ld returned 1 exit status

 
 
 

Linking problem

Post by eric » Thu, 25 Oct 2001 22:13:02



> Hi. I'm trying to compile a program and it fails in the linking phase.
> The compile lines I use are:

> g++ -g -O2 -D_REENTRANT -D_GNU_SOURCE -D_THREAD_DAFE -c
> novraSG50_trap_app.cpp
> g++ -L/usr/local/lib -ls50MgmtStatus -lccxx -lccstd -lccio -lpthread
> -ldl -lz -ls50MgmtStatus  -lccstd -lccxx -lccio -ldl -lz -lpthread
> novraSG50_trap_app.o -o sg50trapapp

move all of your library references after your .o references.  if your
linker is a single pass linker it doesn't forward check symbols it is
only carrying undefined refs to the next object to see if they are
getting resolved.

hope this helps,

Eric

 
 
 

Linking problem

Post by Paul Pluzhniko » Sun, 28 Oct 2001 16:10:58



Quote:> Hi. I'm trying to compile a program and it fails in the linking phase.
> The compile lines I use are:

> g++ -g -O2 -D_REENTRANT -D_GNU_SOURCE -D_THREAD_DAFE -c
> novraSG50_trap_app.cpp
> g++ -L/usr/local/lib -ls50MgmtStatus -lccxx -lccstd -lccio -lpthread
> -ldl -lz -ls50MgmtStatus  -lccstd -lccxx -lccio -ldl -lz -lpthread
> novraSG50_trap_app.o -o sg50trapapp

> I get 'undefined reference' errors in the linking phase for functions,
> objects etc. defined in the static library libs50MgmtStatus.a which I
> link. I'm quite confident that the linking order is correct (that's why
> I also link the libraries twice just in case) and the libraries are fine
> (have been used before) and the lib path is specified. Does anybody have
> an idea what the error might be? Any info/help would be greatly
> appreciated. Thanks.

Even though you are confident that the linking order is correct, it is not.
The objects (novraSG50_trap_app.o) should be followed by libraries, not the
other way around.

See also:
http://groups.google.com/groups?hl=en&threadm=qt7B7.4096%24AQ6.384368...
read2.prod.itd.earthlink.net

 
 
 

1. Metro Link Motif linking problem

I am having a problem linking an X/Motif application with the static libraries
in Metro Link Motif 2.0.1.   If I add the -static directive in the makefile I
get "undefined reference" errors for everything in the Motif libs.  I checked
and all of the .a files are there with the .so files.  I used nm to verify each
of the unresolved symbols was actually contained in the libraries I specified in
the make.  Another application that is built by the same makefile that doesn't
use any X or Motif libs compiles fine(statically) and grows tenfold in size.  I
also tried to build the .a files directly(with fully qualified pathname) instead
of using -l and had the same problem.  Any ideas???

Thanks,
bill

2. Shadow file trashed on software RAID

3. 2.4.18 linking problem - ?configuration options problem?

4. Message Queue + Sockets Multiplexing

5. Problems compiling fvwm => linking problem

6. ANNOUNCE: change-sun-hostid 1.7.0 released

7. xwave linking problems "undefined reference"

8. Linux PC in TV studio

9. X library link problems

10. Strange linking problem (__divss,__divus)

11. HELP: linking problem on Linux

12. fvwm-1.24r link problem

13. GhostScript compilation/linking problem