[CMake] visual studio tries to link to non-existent static version of lib
Nils Gladitz
nilsgladitz at gmail.com
Tue Aug 23 15:44:29 EDT 2016
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
More information about the CMake
mailing list