[CMake] How to link against a static lib under windows/minGW
Joachim Ziegler
ziegler at mpi-sb.mpg.de
Thu Oct 30 10:33:33 EDT 2008
Hendrik Sattler wrote:
>> Ok, I have the files
>>
>> libnspr4.dll
>> libnspr4.lib
>> libnspr4_s.dll
>>
>> where the last one should be the static library ("_s").
>
> No. A DLL is a "dynamic link library". It may be linked statically
> itself but that doesn't mean that you can link statically against it.
OK, then libnspr4_s.dll must be some other lib, maybe a debug version.
Anyway, changing the CMakeLists line
TARGET_LINK_LIBRARIES(testPR nspr4 Ws2_32)
(with which linking works fine)) just to
TARGET_LINK_LIBRARIES(testPR nspr4_s Ws2_32)
prevents the linker from finding the library:
D:\MinGW\bin\g++.exe CMakeFiles\testPR.dir\PRifdefd.cpp.obj -o
testPR.exe
-Wl,--out-implib,libtestPR.dll.a
-Wl,--major-image-version,0,--minor-image-version,0 -LD:\nspr-4.6\lib
-lnspr4_s -lWs2_32
D:\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe:
cannot find -lnspr4_s
(?)
More information about the CMake
mailing list