c++ - Linking against a debug version of a library with CMake -


i've got problems linking against debug version of lib. use cmake make library:

project(mylib) ... add_library(mylib shared ${sources}) 

i launch build 2 times release , debug version of lib. add 'd' suffix name of debug lib , have mylib.dll , mylibd.dll.

in app explicitly link against debug dll:

project(myapp) add_executable(myapp win32 ${sources}) target_link_libraries(myapp mylibd.dll) 

the build finishes successfully, when open resulting exe file dependency walker unresolved dependency mylib.dll file, though debug version (mylibd.dll) located in same folder.

so, why app try use release version of lib @ runtime? , how link against debug version?

you should not rename file manually. use cmake's cmake_debug_postfix variable or debug_postfix target property instead:

add_library(mylib shared ${sources}) set_target_properties(mylib properties debug_postfix "d")  [...] add_executable(myapp win32 ${sources}) target_link_libraries(myapp mylib) 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -