[cmake-developers] [CMake 0016059]: It is not possible to specify a linker different from the compiler to link a shared library
Mantis Bug Tracker
mantis at public.kitware.com
Tue Apr 12 12:00:44 EDT 2016
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
======================================================================
More information about the cmake-developers
mailing list