I want to make a C++ application that can handle python plugins, so i'm getting into boost.python. I'm creating some test programs that I build with CMake.
In my test program, I have a simple "library" that propose a plugin interface (using boost.python to expose this to python), and a plugin loader (not coded yet, nothing inside).
When I try to build my executable directly (without any libraries), I get a link error (module I've exposed is called pythonPlugin) :
duplicate symbol _initpythonPlugin in:
CMakeFiles/pythonPluginer.dir/main.cpp.o
libcoreLib.a(PluginLoader.cpp.o)
duplicate symbol __Z24init_module_pythonPluginv in:
CMakeFiles/pythonPluginer.dir/main.cpp.o
libcoreLib.a(PluginLoader.cpp.o)
I have the same result when I build an intermediate static library. However, when I turn this library into a shared one, this works fine. Here is a sub CMakeList.txt :
file(GLOB sources core/*.h core/*.cpp )
add_library(coreLib SHARED ${sources})
target_link_libraries(coreLib
${PYTHON_LIBRARIES}
${Boost_LIBRARIES})
add_executable(pythonPluginer main.cpp)
target_link_libraries(pythonPluginer
coreLib)
Do you have any explanation to this ? Is it possible to make a program with boost/python without using shared libraries ?
Thanks, Denis.
我会尝试从file(GLOB ...)命令中删除core / *。h头文件不需要编译,这实际上可能会导致符号重复的问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.