我整天试图解决此错误,但没有结果。 使用代码块+ mingw + cmake进行编译 image
||=== Build: all in otclient (compiler: GNU GCC Compiler) ===|
undefined reference to `vtable for boost::detail::thread_data_base'|
undefined reference to `boost::thread::start_thread_noexcept()'|
undefined reference to `boost::thread::join_noexcept()'|
undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
undefined reference to `boost::detail::thread_data_base::~thread_data_base()'|
||error: ld returned 1 exit status|
CMakeFiles\otclient.dir\build.make|2272|recipe for target 'otclient.exe' failed|
CMakeFiles\Makefile2|71|recipe for target 'CMakeFiles/otclient.dir/all' failed|
C:\Users\Tomek\Desktop\compile\Makefile|128|recipe for target 'all' failed|
||=== Build failed: 9 error(s), 0 warning(s) (8 minute(s), 25 second(s)) ===|
答案 0 :(得分:0)
我的cmakeLists:
cmake_minimum_required(VERSION 3.6)
project(otclient)
set(VERSION "0.6.6")
option(FRAMEWORK_SOUND "Use SOUND " ON)
option(FRAMEWORK_GRAPHICS "Use GRAPHICS " ON)
option(FRAMEWORK_XML "Use XML " ON)
option(FRAMEWORK_NET "Use NET " ON)
option(FRAMEWORK_SQL "Use SQL" OFF)
include(src/framework/CMakeLists.txt)
include(src/client/CMakeLists.txt)
# functions map for reading backtraces
if(NOT APPLE)
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-Map=${PROJECT_NAME}.map")
endif()
option(USE_PCH "Use precompiled header (speed up compile)" OFF)
set(executable_SOURCES
src/main.cpp
)
# add executable icon for win32 platforms
if(WIN32)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o
COMMAND ${CMAKE_RC_COMPILER}
-I${CMAKE_CURRENT_SOURCE_DIR}/src
-i${CMAKE_CURRENT_SOURCE_DIR}/src/otcicon.rc
-o ${CMAKE_CURRENT_BINARY_DIR}/otcicon.o)
set(executable_SOURCES ${executable_SOURCES} otcicon.o)
endif()
if(MINGW)
add_definitions(-DWIN32)
endif()
add_definitions(-D"VERSION=\\"${VERSION}\\"")
# add client executable
set(CMAKE_CXX_STANDARD 11)
find_package(Boost COMPONENTS thread system REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
add_executable(${PROJECT_NAME} ${framework_SOURCES} ${client_SOURCES} ${executable_SOURCES})
target_link_libraries(${PROJECT_NAME} ${framework_LIBRARIES} ${Boost_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIRS})
if(USE_PCH)
include(cotire)
cotire(${PROJECT_NAME})
message(STATUS "Use precompiled header: ON")
else()
message(STATUS "Use precompiled header: OFF")
endif()
# installation
set(DATA_INSTALL_DIR share/${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES README.md BUGS LICENSE AUTHORS init.lua ${PROJECT_NAME}rc.lua DESTINATION ${DATA_INSTALL_DIR})
install(DIRECTORY data modules DESTINATION ${DATA_INSTALL_DIR} PATTERN ".git" EXCLUDE)
# add "make run"
add_custom_target(run COMMAND ${PROJECT_NAME} DEPENDS ${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)