J'essaie de créer un fichier CMakeklist.txt sous Windows et j'ai un gros problème.CMake: bibliothèque de liens sur Visual Studio
j'ai écrit
cmake_minimum_required(VERSION 3.1.2)
project(c_api)
set(INC_PATH target/release/deps)
set(PROJECT_DLL traffic.dll)
set(PROJECT_LIB traffic.dll.lib)
configure_file(${INC_PATH}/${PROJECT_DLL} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
include_directories(${INC_PATH}/include)
add_library(traffic UNKNOWN IMPORTED)
set_property(TARGET traffic PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_DLL})
set_property(TARGET traffic PROPERTY IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_LIB})
file(GLOB SOURCES "c_api/examples/ai_module/*.c")
add_executable(ai_module
${SOURCES}
)
target_link_libraries(ai_module traffic)
je lance le projet qui génèrent CMake je suis
LNK1107 invalid or corrupt file: cannot read at 0x2D8
Je pensais que le problème est add_library(traffic UNKNOWN IMPORTED)
mais si je change à add_library(traffic SHARED IMPORTED)
je reçois
LNK2019 unresolved external symbol _traffic_import_osm referenced in function _main ai_module
donc je suppose que Visual Studio ne voit pas une bibliothèque.
Je cours ce code sur linux et je change seulement le format .dll
pour .so
et cela fonctionne très bien.
Im en utilisant Visual Studio 15 2017 sur CMake