与Wl,E联系起来,这是什么意思?

2024-05-06 16:24:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在做一个项目,我们使用的是一个带有CPP-API的Basler派伦相机。除了picture taking之外,我们的大多数代码都是用Python编写的,因此我们使用swig从CPP包装take_image()-函数。在

下面是我们对swig和g++的调用:

swig -python -c++ frompytocpp.i

g++ -c -fpic  cppcamera.cpp frompytocpp_wrap.cxx
-I/opt/pylon/genicam/library/CPP/include -I/opt/pylon/include -DUSE_GIGE
-I/usr/include/python2.6

g++ -shared cppcamera.o frompytocpp_wrap.o -o _frompytocpp.so
-L/opt/pylon/lib64 -L/opt/pylon/lib -L/opt/pylon/genicam/bin/Linux64_x64
-L/opt/pylon/genicam/bin/Linux64_x64/GenApi/Generic -Wl,-E -lpylonbase
-lpylonutility

它编译得很好,但是在运行时尝试创建一个camera对象时,会抛出一个似乎与未解析符号相关的异常。根据cameraapi手册,标志-Wl,-E非常关键,“否则链接器在运行时将无法正确识别和匹配挂架符号”。我查找了g++的手册页,意识到-Wl用于将选项传递给链接器,但无法确定-E选项在传递给-Wl时会做什么。有人吗?在

运行时问题只在从python调用拍照函数时才会显现出来。所以只是标准编译cppcamera.cpp合并-Wl,-E可以很好地工作,但是当我们创建python中包装器使用的共享库时,有些东西是不正确的/缺少的。有没有关于g++调用中可能缺少的内容的建议?在


Tags: 函数binincludecppswigoptpylonx64
1条回答
网友
1楼 · 发布于 2024-05-06 16:24:02

您可以检查help manual of ^{}(如果gcc设置为使用ld作为链接器):

-E
export-dynamic
no-export-dynamic

When creating a dynamically linked executable, using the -E option or the export-dynamic option causes the linker to add all symbols to the dynamic symbol table. The dynamic symbol table is the set of symbols which are visible from dynamic objects at run time.

If you do not use either of these options (or use the no-export-dynamic option to restore the default behavior), the dynamic symbol table will normally contain only those symbols which are referenced by some dynamic object mentioned in the link.

If you use dlopen to load a dynamic object which needs to refer back to the symbols defined by the program, rather than some other dynamic object, then you will probably need to use this option when linking the program itself.

You can also use the dynamic list to control what symbols should be added to the dynamic symbol table if the output format supports it. See the description of dynamic-list.

相关问题 更多 >