By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,301 Members | 1,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,301 IT Pros & Developers. It's quick & easy.

g++ linking error: undefined reference

P: n/a
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.
Emanuele Torrenti
Linux engine 2.6.17-11-generic i686 GNU/Linux
Mar 29 '07 #1
Share this Question
Share on Google+
2 Replies

P: n/a

Manuel T wrote:
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, and is a FAQ there, here
probably too.

Bernd Strieder

Mar 29 '07 #2

P: n/a
Bernd Strieder wrote:

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

g++ -L/usr/lib $(OBJS) $(USER_OBJS) $(LIBS) -o puma200CS
Done, but same error...
The question belongs into, 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.

Linux engine 2.6.17-11-generic i686 GNU/Linux
Mar 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.