I am stuck in a problem with Cmake on Windows 10. I am using cmake with vcpkg to build an application linking to Boost thread (actually, I developed it on Ubuntu and I am now trying to build it also for Windows..)
The problem that I receive is:
boost_thread-vc140-mt.lib (thread.obj): error LNK2038: mismatch detected for 'RuntimeLibrary': the value 'MT_StaticRelease' does not match the value 'MDd_DynamicDebug 'in mtconnect_get_data.obj
Here is my Cmake file:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(mtconnect)
set(FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR "C:/Program Files/MySQL/Connector C++ 8.0")
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/jdbc)
include_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/include/jdbc/cppconn)
link_directories(${FULL_PATH_TO_MYSQL_CONNECTOR_CPP_DIR}/lib64/vs14)
set(Boost_INCLUDE_DIR ${_VCPKG_INSTALLED_DIR}/x64-windows-static/include)
find_package(Boost REQUIRED COMPONENTS thread)
include_directories(include ${Boost_INCLUDE_DIRS})
find_package(CURL CONFIG REQUIRED)
include_directories(${CURL_INCLUDE_DIRS})
set(FULL_PATH_TO_LIBCONFIG_DIR my_libconfig_path)
include_directories(${FULL_PATH_TO_LIBCONFIG_DIR}/include)
link_directories(${FULL_PATH_TO_LIBCONFIG_DIR}/lib)
find_library(LIBCONFIGPP_LOCATION libconfig++)
set(FULL_PATH_TO_PTHREAD_DIR my_pthread_path )
include_directories(${FULL_PATH_TO_PTHREAD_DIR}/include)
link_directories(${FULL_PATH_TO_PTHREAD_DIR}/lib/x64)
include_directories(include)
set(Boost_NO_SYSTEM_PATHS true)
set (Boost_USE_STATIC_LIBS OFF CACHE BOOL "use static libraries from Boost")
set (Boost_USE_MULTITHREADED ON)
if (WIN32)
add_definitions( -DBOOST_ALL_NO_LIB )
add_definitions( -DBOOST_ALL_DYN_LINK )
endif()
add_executable(mtconnect_create_data src/mtconnect_create_data.cpp)
add_executable(mtconnect_get_data src/mtconnect_get_data.cpp include/AsioTelnetClient.cpp)
target_link_libraries(mtconnect_create_data ${CURL_LIBRARY} ${Boost_LIBRARIES})
target_link_libraries(mtconnect_get_data ${CURL_LIBRARY} ${Boost_LIBRARIES}
mysqlcppconn ${LIBCONFIGPP_LOCATION} pthread)
...it seems to me to be solved by adding
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
just before the add_executable line and building only the release
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.