g++ linking and swig

只愿长相守 提交于 2019-12-24 15:27:01

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/5302933/g-linking-and-swig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!