0
我正在创建一个基于Qt的应用程序,需要从中运行python代码。为此,我使用Boost.Python。我的错误是:在使用Boost进行C++ python绑定时找不到错误
CMakeFiles/App.dir/main.cpp.o: In function `_GLOBAL__sub_I_main.cpp':
main.cpp:(.text.startup+0x3): undefined reference to `_Py_NoneStruct'
collect2: error: ld returned 1 exit status
make[2]: *** [source/App] Error 1
make[1]: *** [source/CMakeFiles/App.dir/all] Error 2
make: *** [all] Error 2
11:12:47: The process "/usr/local/bin/cmake" exited with code 2.
Error while building/deploying project App (kit: Desktop Qt 5.7.0 GCC 64bit)
When executing step "Make"
我相信错误是链接错误,但我不知道如何删除它。我刚刚开始使用cmake,并没有精通它。 代码在这里: https://github.com/daemonSlayer/App
我应该在代码中改变它以使其工作?
编辑:
[/根]的CMakeLists.txt:
cmake_minimum_required(VERSION 3.3)
# Default configuration values. These must be before the project command or
# they won't work in Windows.
# If no build type is specified, default to "Release"
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"None Debug Release RelWithDebInfo MinSizeRel"
FORCE)
endif()
# Install to "dist" directory in Windows for testing and as a staging directory
# for the installer.
if (WIN32 AND NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX dist CACHE STRING "Install path prefix.")
endif()
project(App)
set(PROJECT_LONGNAME "DeepLearningApp")
set(PROJECT_VERSION "0.0.1")
# Global CMake options
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
# Configure Qt
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Test REQUIRED)
# Configure Boost
find_package(python)
find_package(Boost REQUIRED)
if (NOT MSVC)
# Enable the C++11 standard
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11)
endif()
# Testing configuration
enable_testing()
set(TEST_LINK_LIBRARIES Qt5::Test)
add_subdirectory(source)
add_subdirectory(tests)
if (WIN32)
[/根/来源]的CMakeLists.txt:
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/defines.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/defines.h)
file(GLOB_RECURSE UI_FILES *.ui)
file(GLOB_RECURSE CODE_FILES *.cpp)
qt5_wrap_ui(UI_HEADERS ${UI_FILES})
qt5_add_resources(RESOURCE_FILES ../resources/resources.qrc)
# Windows application icon
if (WIN32)
set(WINDOWS_RES_FILE ${CMAKE_CURRENT_BINARY_DIR}/resources.obj)
if (MSVC)
add_custom_command(OUTPUT ${WINDOWS_RES_FILE}
COMMAND rc.exe /fo ${WINDOWS_RES_FILE} resources.rc
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/win
)
else()
add_custom_command(OUTPUT ${WINDOWS_RES_FILE}
COMMAND windres.exe resources.rc ${WINDOWS_RES_FILE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/win
)
endif()
endif()
add_executable(${CMAKE_PROJECT_NAME} WIN32
${UI_HEADERS}
${CODE_FILES}
${RESOURCE_FILES}
${WINDOWS_RES_FILE}
)
target_link_libraries(${CMAKE_PROJECT_NAME}
Qt5::Widgets
)
# Configure Python
find_package(PythonLibs 2.7 REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
# Configure Boost
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME}
${Boost_LIBRARIES})
if (UNIX)
install(TARGETS ${CMAKE_PROJECT_NAME}
RUNTIME DESTINATION bin)
elseif (WIN32)
install(TARGETS ${CMAKE_PROJECT_NAME}
DESTINATION .)
endif()
add_subdirectory(win)
endif()
欢迎来到SO!尝试创建一个[最小,完整,可验证的示例](http://stackoverflow.com/help/mcve)并在您的问题中包含代码。请勿将您的帖子的关键部分链接到外部网站,因为这些服务可能会倒闭。 –
请向我们展示CMakeLists.txt,然后找出问题会容易得多。 –
我编辑了这个问题并包含了cmake文件。请解释所需的更改。 –