On 23.08.2016 21:36, Jack Stalnaker wrote:
The following works on Linux, for both GNU and Intel compilers:

add_library(mylib SHARED ${mylib_sources})
target_link_libraries(mylib ${mylib_libraries})
...
add_executable(test_mylib test_mylib.c)
target_link_libraries(test_mylib mylib ${test_mylib_libraries})
add_test (TestMylib test_mylib)


However on windows, using Visual Studio, building test_mylib fails with the message "cannot open file Debug\mylib.lib". But I have not asked for a static library, and I'm not sure why VS is trying to link to it. Is there some extra step I need to take to make this work on Windows?

mylib.lib is the import library [1] for your DLL.
The linker is (probably) not creating it because you aren't exporting any symbols [2].

Nils

[1] https://en.wikipedia.org/wiki/Dynamic-link_library#Import_libraries
[2] https://msdn.microsoft.com/en-us/library/z4zxe9k8.aspx
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to