1

我正在尝试将 CGAL 合并到现有的模拟项目中,但是遇到了一些链接器问题。python 模拟 keiro.py 在 swig 包装器中使用了一个名为physics.cpp 的文件来加速常见操作......我设法让我的physics.cpp 文件进行编译,但是运行Python 模拟错误并显示以下消息:

回溯(最后一次调用):文件“keiro.py”,第 2 行,从世界导入 World,查看文件“/Users/marcstrauss/Desktop/keiro/world.py”,第 9 行,从 fast.physics 导入Vec2d, Particle, World as PhysicsWorld 文件“/Users/marcstrauss/Desktop/keiro/fast/physics.py”,第 7 行,在 import _physics ImportError: dlopen(/Users/marcstrauss/Desktop/keiro/fast/physics.so , 2):符号未>找到:_ _gmpq_clear 引用自:/Users/marcstrauss/Desktop/keiro/fast/_physics.so 预期于:/Users/marcstrauss/Desktop/keiro/fast/_physics.so 中的平面命名空间

我认为目标文件中未识别 ___gmpq_clear 符号的错误意味着我没有正确链接到 CGAL。这是我的生成文件:

全部:physics.py _physics.so graphutils.py _graphutils.so

_physics.so:setup_physics.pyphysics_wrap.cxxphysics.cpp python setup_physics.py build_ext --inplace -I/opt/local/include/

_graphutils.so: setup_graphutils.py graphutils_wrap.cxx graphutils.cpp python setup_graphutils.py build_ext --inplace -I/opt/local/include/

physics.pyphysics_wrap.cxx:physics.iphysics.h swig -python -c++physics.i

graphutils.py graphutils_wrap.cxx: graphutils.i graphutils.h swig -python -c++ graphutils.i -I/opt/local/include/ clean: rm -f Physics.py rm -f graphutils.py rm -f *.cxx rm -f *~ *.pyc *.pyo rm -f *.so rm -rf build

有没有人对我有任何关于如何解决这个问题的想法?谢谢!

4

1 回答 1

6

在我的计算机上,该__gmpq_clear符号位于 libgmp 库中:

nm libgmp.a | grep gmpq_clear
00000000 T __gmpq_clear

尝试添加-lgmp到您的链接命令。

于 2010-11-03T00:57:20.727 回答