This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Linking with static libgsl.a
- From: <banerjee at wernicke dot ccn dot upenn dot edu>
- To: gsl-discuss at sources dot redhat dot com
- Date: Thu, 21 Feb 2002 18:02:19 -0500 (EST)
- Subject: Linking with static libgsl.a
Folks,
I am writing a vector (as in an element of a vector space, not <vector>)
that basically consists of wrapping methods around existing gsl_vector
functions.
I wrote a program, main.cpp, to test out my VB_Vector class. GSL comes
with both static and shared libraries and I am trying to link with the
static library.
Here's the compilation line for vb_vector.o (the object file of my vector
class):
g++ -DDEBUG -g -c -Wall -O3 ./vb_vector.cpp -I../include
-I/usr/local/include/gsl -I/home/banerjee/tar_code/libvoxbo
Here's the line for compiling main.cpp:
g++ -static -DDEBUG -g -Wall -O3 -o main main.cpp
-I/usr/local/include/gsl -I./include -I/home/banerjee/tar_code/libvoxbo
-L./ -L ./lib -L/usr/local/lib -lgslcblas -lgsl -lm -lvbutils
(-lvbutils ==> a library I created, which contains vb_vector.o and other
object files).
I get errors of the type:
./lib/libvbutils.a(vb_vector.o): In function
`VB_Vector::VB_Vector(gsl_vector const *)':
/home/banerjee/tar_mat/src/./vb_vector.cpp:99: undefined reference to
`gsl_vector_memcpy'
So libgsl.a is not getting linked. If I have a call to gsl_vector_memcpy()
in main.cpp (and not just in vb_vector.cpp), gsl_vector_memcpy()
does get linked into the executable. The other way I found to guarantee
that gsl_vector_memcpy gets linked in, is to add "-u gsl_vector_memcpy"
to the compilation line for main.cpp.
What am I missing? Is this somehow related to name mangling?
Thanks.
K. Banerjee