clion下C++调用Python,要怎么配置,cmake里加入python库了,之前用C可以,现在用C++不行了
cmake文件
cmake_minimum_required(VERSION 3.13)
project(server)
set(CMAKE_CXX_STANDARD 14)
add_executable(server main.cpp HttpRequest.h HttpServer.h ThreadPool.h)
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBIARIES})
find_package(Threads)
target_link_libraries (${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT})
编译报错
/home/tak/CLionProjects/server/main.cpp:8: undefined reference to `Py_Initialize'
/home/tak/CLionProjects/server/main.cpp:9: undefined reference to `PyRun_SimpleStringFlags'
/home/tak/CLionProjects/server/main.cpp:10: undefined reference to `PyRun_SimpleStringFlags'
/home/tak/CLionProjects/server/main.cpp:12: undefined reference to `PyImport_ImportModule'
/home/tak/CLionProjects/server/main.cpp:13: undefined reference to `PyObject_GetAttrString'
/home/tak/CLionProjects/server/main.cpp:14: undefined reference to `PyTuple_New'
/home/tak/CLionProjects/server/main.cpp:15: undefined reference to `Py_BuildValue'
/home/tak/CLionProjects/server/main.cpp:15: undefined reference to `PyTuple_SetItem'
/home/tak/CLionProjects/server/main.cpp:16: undefined reference to `PyEval_CallObjectWithKeywords'
/home/tak/CLionProjects/server/main.cpp:17: undefined reference to `PyArg_Parse'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论