MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0015495 | CMake | CMake | public | 2015-04-04 01:31 | 2015-11-02 09:13 |
Reporter | Norbert Pfeiler | ||||
Assigned To | |||||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | suspended | ||
Platform | OS | OS Version | |||
Product Version | CMake 3.2.1 | ||||
Target Version | Fixed in Version | ||||
Summary | 0015495: cmake prevents linking static runtime with absolute path to a static lib | ||||
Description | When an absolute path to a static lib i.e. ${ZLIB_LIBRARIES}, which expands to D:/msys64/mingw64/lib/libz.a is added to target_link_libraries, the library is linked using its name (-lz), preprended with -Wl,-Bstatic and appended with -Wl,-Bdynamic. Because the libraries appear after any link flags, the latter one cancels out any flags to link statically (-static -static-libstdc++ -static-libgcc) and the final executable links against the dynamic runtime. Using an imported target i.e. ZLIB::ZLIB, the library is added using its absolute path without any additional flags. | ||||
Steps To Reproduce | add static link flags add static lib via its absolute path the final executable links against the dynamic runtime | ||||
Additional Information | [1/4] D:\msys64\mingw64\bin\c++.exe -MMD -MT CMakeFiles/static_lib_test1.dir/main.cpp.obj -MF CMakeFiles/static_lib_test1.dir/main.cpp.obj.d -o CMakeFiles/static_lib_test1.dir/main.cpp.obj -c ../main.cpp [2/4] D:\msys64\mingw64\bin\c++.exe -isystem D:/msys64/mingw64/include -MMD -MT CMakeFiles/static_lib_test2.dir/main.cpp.obj -MF CMakeFiles/static_lib_test2.dir/main.cpp.obj.d -o CMakeFiles/static_lib_test2.dir/main.cpp.obj -c ../main.cpp [3/4] cmd.exe /C "cd . && D:\msys64\mingw64\bin\c++.exe CMakeFiles/static_lib_test1.dir/main.cpp.obj -o static_lib_test1.exe -Wl,--out-implib,libstatic_lib_test1.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -static -static-libstdc++ -static-libgcc -Wl,-Bstatic -lz -Wl,-Bdynamic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." [4/4] cmd.exe /C "cd . && D:\msys64\mingw64\bin\c++.exe CMakeFiles/static_lib_test2.dir/main.cpp.obj -o static_lib_test2.exe -Wl,--out-implib,libstatic_lib_test2.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -static -static-libstdc++ -static-libgcc D:/msys64/mingw64/lib/libz.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." static_lib_test1.exe: ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x777d0000) kernel32.dll => /c/Windows/system32/kernel32.dll (0x776b0000) KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefd7b0000) msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefde30000) libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x6fc40000) libgcc_s_seh-1.dll => /mingw64/bin/libgcc_s_seh-1.dll (0x61440000) libwinpthread-1.dll => /mingw64/bin/libwinpthread-1.dll (0x64940000) USER32.dll => /c/Windows/system32/USER32.dll (0x775b0000) GDI32.dll => /c/Windows/system32/GDI32.dll (0x7fefe110000) LPK.dll => /c/Windows/system32/LPK.dll (0x7feffad0000) USP10.dll => /c/Windows/system32/USP10.dll (0x7fefd950000) IMM32.DLL => /c/Windows/system32/IMM32.DLL (0x7fefde00000) MSCTF.dll => /c/Windows/system32/MSCTF.dll (0x7fefdca0000) static_lib_test2.exe: ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x777d0000) kernel32.dll => /c/Windows/system32/kernel32.dll (0x776b0000) KERNELBASE.dll => /c/Windows/system32/KERNELBASE.dll (0x7fefd7b0000) msvcrt.dll => /c/Windows/system32/msvcrt.dll (0x7fefde30000) | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | cmake static lib test.7z (639) 2015-04-04 01:31 https://public.kitware.com/Bug/file/5420/cmake%20static%20lib%20test.7z | ||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2015-04-04 01:31 | Norbert Pfeiler | New Issue | |||
2015-04-04 01:31 | Norbert Pfeiler | File Added: cmake static lib test.7z | |||
2015-04-06 08:31 | Brad King | Note Added: 0038406 | |||
2015-04-06 08:32 | Brad King | Status | new => resolved | ||
2015-04-06 08:32 | Brad King | Resolution | open => suspended | ||
2015-04-07 09:03 | Brad King | Note Added: 0038462 | |||
2015-11-02 09:13 | Robert Maynard | Note Added: 0039759 | |||
2015-11-02 09:13 | Robert Maynard | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|