【发布时间】:2020-01-17 07:18:36
【问题描述】:
我想在 Python 中使用 C++ 函数。因此,我决定尝试为此目的使用 SWIG。 首先,我运行命令:
swig -python test.i
然后用g++-6.2编译如下:
g++-6.2 -c test.cpp test_wrap.c -fPIC -I /usr/include/python3.6m
到目前为止,一切正常,但在必须创建链接的最后一步出现问题。我运行命令:
ld -shared test.o test_wrap.o -o _test.so
正如Swig tutorial 中的建议,但我收到以下错误:
test.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x66): undefined reference to `__dso_handle'
ld: test.o: relocation R_X86_64_PC32 against undefined hidden symbol `__dso_handle' can not be used when making a shared object
ld: final link failed: Bad value
有谁知道如何解决这个问题?
【问题讨论】:
-
链接期间似乎缺少 vDSO 库。