The following issue has been SUBMITTED. ====================================================================== https://cmake.org/Bug/view.php?id=16059 ====================================================================== Reported By: Antonio Assigned To: ====================================================================== Project: CMake Issue ID: 16059 Category: CMake Reproducibility: always Severity: minor Priority: normal Status: new ====================================================================== Date Submitted: 2016-04-12 12:00 EDT Last Modified: 2016-04-12 12:00 EDT ====================================================================== Summary: It is not possible to specify a linker different from the compiler to link a shared library Description: In some situations, it might be convenient to specify a different linker than the compiler. For example, for llvm combined with mingw, compiling with clang and linking with gcc would work. The workaround proposed here https://cmake.org/pipermail/cmake/2014-August/058268.html does not seem to work.
Steps to Reproduce: Requires 2 compilers to be there. In the attached project, Configuring with D:\dummyProj\build> cmake ..\src -G "Eclipse CDT4 - Ninja" -DCMAKE_TOOLCHAIN_FILE=..\src\Toolchain-LLVM.cmake -DCMAKE_LINKER=C:/Programs/mingw32_493_posix_dwarf/bin/g++.exe -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -DCMAKE_CXX_CREATE_SHARED_LIBRARY="<CMAKE_LINKER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" Building will anyway lead to the following commands to be generated: [1/2] C:\Programs\LLVM\bin\clang++.exe -Ddummy_EXPORTS -MMD -MT CMakeFiles/dummy.dir/dummy.cpp.obj -MF CMakeFiles/dummy.dir/dummy.cpp.obj.d -o CMakeFiles/dummy.dir/dummy.cpp.obj -c D:/dummyProj/src/dummy.cpp [2/2] cmd.exe /C "cd . && C:\Programs\LLVM\bin\clang++.exe -shared -o libdummy.dll -Wl,--out-implib,libdummy.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/dummy.dir/dummy.cpp.obj -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." FAILED: cmd.exe /C "cd . && C:\Programs\LLVM\bin\clang++.exe -shared -o libdummy.dll -Wl,--out-implib,libdummy.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/dummy.dir/dummy.cpp.obj -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ." C:\Programs\mingw32_493_posix_dwarf\i686-w64-mingw32\lib/libmingw32.a(lib32_libmingw32_a-pseudo-reloc.o):pseudo-reloc.c:(.text+0x1d6): undefined reference to `__chkstk_ms' clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. The first command is correct, the second doesn't use g++ to link as desired. Linking succeeds if g++ is replaced in the command line. ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2016-04-12 12:00 Antonio New Issue 2016-04-12 12:00 Antonio File Added: dummyProj.zip ====================================================================== -- 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-developers