python - g++ 链接和 swig

标签 python compiler-construction linker swig gsl

我有一个 cpp 文件,其中包含我在 python 中通过 SWIG 使用的函数。我使用以下命令来编译源代码并创建与 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

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

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

我尝试将 -lgsl -lgslcblas -lm 添加到 swig 编译的行中,但我得到了

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 库?谢谢

最佳答案

正如警告消息所述,Swig 不进行链接。将 -lgsl 等放在链接命令上,这是您的最后一个 g++ 命令。

关于python - g++ 链接和 swig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5302933/

相关文章:

c++ - 来自内置类型的 python 转换器

python - 在 keras 中可视化训练神经网络的权重

c - 未定义对 `initscr' Ncurses 的引用

python - 是否可以检查 python 源代码是否只为一个版本(python 2 或 python 3)编写

python - 如何将列表中的多个字典 append 到另一个包含 "inner"字典的特定部分的列表?

asp.net - 使用 NAnt 中的 ASP 编译器构建 ASP .Net MVC 应用程序

math - 找到两个函数的等价性是不可判定的吗?

mac 的 c 编译器不是 xcode

c++ - linux/g++ 链接的多重定义

将多个 C 源文件编译成一个唯一的目标文件