这可能是一个非常基本的问题,但我无法在任何地方找到解决方案。我正在使用 Boost.Python 在 C++ 中构建 Python 扩展,并且需要将我的项目与 libpcap 链接,但我指定的任何内容似乎都无法将 bjam 指向正确的位置。 Pcap 目前已安装到 /usr/local/include (OS X 10.9),我可以使用 XCode、Make 或任何其他构建系统导入它。然而,当我尝试运行 bjam 时,它给出了链接器错误“架构 x86_64 的未定义符号”。
通过将其他源文件添加到 python 扩展定义中,我克服了第一轮链接器错误,但显然不能对外部库执行相同的操作。这是我的 bjam 文件(从他们的示例中复制并稍作修改):
import python ;
if ! [ python.configured ]
{
ECHO "notice: no Python configured in user-config.jam" ;
ECHO "notice: will use default configuration" ;
using python ;
}
use-project boost : ../../../Downloads/boost_1_55_0 ;
# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is
# /boost/python.
project
: requirements
<library>/boost/python//boost_python
<implicit-dependency>/boost//headers
: usage-requirements <implicit-dependency>/boost//headers
;
python-extension pcap_ext : PacketWarrior/pcap_ext.cc PacketWarrior/PacketEngine.h PacketWarrior/PacketEngine.cc PacketWarrior/Packet.h ;
# Put the extension and Boost.Python DLL in the current directory, so
# that running script by hand works.
install convenient_copy
: pcap_ext
: <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
<location>.
;
# A little "rule" (function) to clean up the syntax of declaring tests
# of these extension modules.
local rule run-test ( test-name : sources + )
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
}
# Declare test targets
run-test pcap : pcap_ext pcap.py ;
我确信它只是在项目需求中添加了一些东西,但语法让我困惑,并且没有任何变化<libary>
我发现 [0] 似乎有效。我尝试寻找将 llibpcap 标志传递给 GCC 的等效项,但无济于事。非常感谢任何指导!
[0] - https://wiki.python.org/moin/boost.python/BuildingExtensions https://wiki.python.org/moin/boost.python/BuildingExtensions
弄清楚了。当需要动态库时,我试图链接到标头路径。我将其添加到需求规则中,bjam 能够正确编译它。
<library>/usr/lib/libpcap.dylib
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)