Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > g++ linking error: undefined reference

Reply
Thread Tools

g++ linking error: undefined reference

 
 
Manuel T
Guest
Posts: n/a
 
      03-29-2007
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
 
Reply With Quote
 
 
 
 
Bernd Strieder
Guest
Posts: n/a
 
      03-29-2007
Hello,

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 gnu.gcc.help, and is a FAQ there, here
probably too.

Bernd Strieder

 
Reply With Quote
 
 
 
 
Manuel T
Guest
Posts: n/a
 
      03-29-2007
Bernd Strieder wrote:

> Hello,
>
> 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 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
--
Linux engine 2.6.17-11-generic i686 GNU/Linux
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message (undefined reference) Linking Issue. israphelr@googlemail.com C++ 0 03-06-2009 05:58 PM
undefined reference error while linking..help yeah C++ 1 12-04-2007 02:22 PM
Problem linking netcdf - Undefined References... lars.uffmann@rwth-aachen.de C++ 5 08-21-2006 03:40 AM
dinkumware 402 linking with g++ 3.x/ _Winit undefined ref Igor C++ 13 12-11-2003 08:59 PM
Undefined Reference Error while linking with g++, STL on LINUX RU C++ 2 08-06-2003 03:28 PM



Advertisments