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文件。請解釋所需的更改。 –