MSVC不会通过cmake生成lib

时间:2018-06-05 04:10:05

标签: visual-c++ cmake

CMakeLists:

if (MSVC)
    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
add_library(${PROJECT_NAME} SHARED ${SOURCES})

CMake 2.8.12 + MSVC 2015

配置输出:

-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMAKE_C_FLAGS_DEBUG is /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
CMAKE_C_FLAGS_RELEASE is /MD /O2 /Ob2 /D NDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO is /MD /Zi /O2 /Ob1 /D NDEBUG
CMAKE_C_FLAGS_MINSIZEREL is /MD /O1 /Ob1 /D NDEBUG
-- Configuring done
-- Generating done

提到https://cmake.org/pipermail/cmake/2009-March/027990.html

  

您很可能没有设置类和/或函数调用   出口。如果没有导出的类/函数,Visual Studio将不会   为您生成一个导入库。

但添加CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON会得到相同的结果。

如何使MSVC生成lib& dll喜欢mingw?

1 个答案:

答案 0 :(得分:0)