g ++链接和swig [英] g++ linking and swig

查看:258
本文介绍了g ++链接和swig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个cpp文件的函数,我在使用SWIG的python。我使用以下命令来编译源代码并创建要与python一起使用的文件。

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

我正在尝试使用在我的源cpp源文件中 GSL 。如果我只是编译GSL文件,我会做

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

我试过将-lgsl -lgslcblas -lm添加到swig编译的行中,但是我get

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

如何链接gsl库?感谢

How can I link the gsl libraries? Thanks

推荐答案

Swig没有链接,如警告消息所示。在链接命令上放置 -lgsl 等,这是你最后一个g ++命令。

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

这篇关于g ++链接和swig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆