Search code examples
pythonlinkerswiggsl

g++ linking and swig


I have a cpp file with functions that I'm using in python with SWIG. I use the following commands to compile the source and create the file to use with python.

swig -c++ -python mini.i
g++ -O2 -c  mini.cpp -I/usr/include/python2.4 -I/usr/lib/python2.4
g++ -O2 -c  mini_wrap.cxx  -I/usr/include/python2.4 -I/usr/lib/python2.4
g++ -shared mini.o mini_wrap.o -o _mini.so

I'm trying now to use GSL in my source cpp source file. If I was just compiling the GSL file I would do

g++ -lgsl -lgslcblas -lm -o mini.o mini.cpp

I've tried adding the -lgsl -lgslcblas -lm to the lines for the swig compile but I get

g++: -lgsl: linker input file unused because linking not done
g++: -lgslcblas: linker input file unused because linking not done
g++: -lm: linker input file unused because linking not done

How can I link the gsl libraries? Thanks


Solution

  • Swig does no linking, as the warning message states. Put the -lgsl etc. on the link command, which is your last g++ command.