g++ linking error: undefined reference

M

Manuel T

Hello everybody,

I'm trying to port a project from Windows+Cygwin to Linux(i'm working on a
Debian-like: Kubuntu), but I'm facing a lot of linking problems.

This project needs libraries xerces and gsl, more specifically libxerces-c,
libgsl, libgslblas. The project comes with an own makefile, automatically
generated by Eclipse cdt on Windows, on wich I made some change to fit it
for Linux.

Compilation step works fine, but when it tries to link tens of .o in an only
one binary, the following error occurs:

../src/utils/kinematic/Kinematics.o: In function
`Kinematics::getInvTransfMatrix(gsl_vector const*, unsigned int)':
Kinematics.cpp:(.text+0x8d): undefined reference to
`DirKin::getInvTransfMatrix(gsl_vector const*, unsigned int)'
collect2: ld returned 1 exit status
make: *** [Puma200CS.exe] Error 1

But the above function doesn't come from any libraries. It's ust user
defined, so it appears in Eclipse's code completion.

How can I get rid of that?

Here is the linker section of the makefile:

****************************************************************
puma200CS: $(OBJS) $(USER_OBJS)
        @echo 'Building target: $@'
        @echo 'Invoking: GCC C++ Linker'
        g++ -L/usr/lib $(LIBS) $(OBJS) $(USER_OBJS) -o puma200CS
        @echo 'Finished building target: $@'
****************************************************************

where $OBJS is a list of tens of .o and $LIBS
is "-lgslcblas -lgsl -lxerces-c", without quotes, of course. Libraries are
correctly installed in /usr/lib, as you can see by -L linker's flag.

I've read somewhere that it's, maybe, a linking order question. I tried to
change the linking order, but no way to work.

Thanks a lot, in advance.
 
B

Bernd Strieder

Hello,

Manuel said:
g++ -L/usr/lib $(LIBS) $(OBJS) $(USER_OBJS) -o puma200CS

g++ -L/usr/lib $(OBJS) $(USER_OBJS) $(LIBS) -o puma200CS

Libs go always after the object files, and libs other libs depend before
them. If you have circular dependencies between libs you have to give
some twice.

The question belongs into gnu.gcc.help, and is a FAQ there, here
probably too.

Bernd Strieder
 
M

Manuel T

Bernd said:
Hello,



g++ -L/usr/lib $(OBJS) $(USER_OBJS) $(LIBS) -o puma200CS

Done, but same error...
The question belongs into gnu.gcc.help, and is a FAQ there, here
probably too.

Thanks a lot... Now I'm studying autoconf & automake(to do more portable
things). I'll post again when i fix all the stuff.

Bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top