This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Problems linking--"undefined reference to..."
- From: Peter Mills <peteymills at hotmail dot com>
- To: cygwin mailing list <cygwin at cygwin dot com>
- Date: Fri, 29 Jan 2010 20:49:20 -0500
- Subject: Problems linking--"undefined reference to..."
I get two rather cryptic errors when I try to compile some of my own software.? In the first, the software links fine normally, but when I
try to add debug information with the -g switch, I get the following
error or something similar:
$ make
g++ -I/home/Petey/include
-Wno-deprecated -g? -o model1 model1.cc -L/home/Petey/lib -ldataset-g
-lpetey -lsparse-g -lgsl -lgslcblas
/tmp/cc5e9G8Z.o: In function
`_ZN7datasetD0Ev':
/home/Petey/include/simple_temp.h:(.dtors+0x0):
undefined reference to `global destructors keyed to x_grid'
/home/Petey/lib/libdataset-g.a(simple_temp-g.o):
In function `_ZN6simpleIdEeqIdEEiRKS_IT_E':
/home/Petey/my_software/datasets/simple_temp.cpp:(.dtors+0x0):
undefined reference to `global destructors keyed to
_ZN6simpleIfE8set_typeEv'
collect2: ld returned 1 exit status
make:
*** [model1] Error 1
(I create multiple versions of the
libraries by appending the optimization flag, e.g. -g, -O2 etc.)
The
second error, and the simpler-looking of the two, is as follows:
g++
-I/home/Petey/include -Wno-deprecated -O2? -o model2 model2.cc
traj_int_obj.o tcoord_defs.o -L/home/Petey/lib -ldataset-O2 -lpetey
-lsparse-O2 -lgsl -lgslcblas
model2.cc: In function `int main(int,
char**)':
model2.cc:140: warning: converting to `long int' from
`double'
traj_int_obj.o:traj_int_obj.cc:(.text+0x12): undefined
reference to `_mcount'
traj_int_obj.o:traj_int_obj.cc:(.text+0x6f):
undefined reference to `_mcount'
traj_int_obj.o:traj_int_obj.cc:(.text+0x165):
undefined reference to `_mcount'
traj_int_obj.o:traj_int_obj.cc:(.text+0x212):
undefined reference to `_mcount'
traj_int_obj.o:traj_int_obj.cc:(.text+0x382):
undefined reference to `_mcount'
traj_int_obj.o:traj_int_obj.cc:(.text+0x702):
more undefined references to `_mcount' follow
There is no variable
or function called "mcount" in traj_int_obj.cc.? The only external
header I use is stdio.h so it must be somehow connected.
Any help
anyone could offer would be greatly appreciated.
Regards,
Peter
Peter Mills
Maverick scientist and software developer
http://sourceforge.net/users/peteysoft/
-Innovative, original and efficient numerical algorithms
http://libagf.sourceforge.net/
-Fast, simple and accurate statistical classification.
_________________________________________________________________
Reinvent how you stay in touch with the new Windows Live Messenger.
http://go.microsoft.com/?linkid=9706116
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple