我遇到了問題,強制CMake使用MSVS鏈接器而不是MinGW 鏈接器。爲了支持MSVC在MSYS我已經實現一個bash腳本迫使CMake的 使用MSVC編譯器創建NMAKE文件:如何使用MSYS在CMake中設置MSVC鏈接器
的cmake -G 「NMAKE Makefile文件」 -DMSVC =真-DCOMPILER_ROOT = $ COMPILER_ROOT -DCMAKE_PROFILE = $ CMAKE_PROFILE -DCMAKE_BUILD_TYPE = $ CMAKE_DEBUG -DCMAKE_CXX_LINKER = $ COMPILER_ROOT /斌/ linker.exe
CMake的正確使用MSVC編譯器和創建NMAKE文件作爲 預期:
$ sh build.sh -msvc /c/binrev/development/vs2010/VC -p
removing CMakeCache.txt
removing temporary directory CMakeFiles
Create MSVC based NMake files.
-- The C compiler identification is MSVC
-- The CXX compiler identification is MSVC
-- Check for CL compiler version
-- Check for CL compiler version - 1600
-- Check if this is a free VC compiler
-- Check if this is a free VC compiler - no
-- Check for working C compiler: c:/binrev/development/vs2010/VC/bin/cl.exe
-- Check for working C compiler: c:/binrev/development/vs2010/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: c:/binrev/development/vs2010/VC/bin/cl.exe
-- Check for working CXX compiler: c:/binrev/development/vs2010/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Execute: brCore.cmake
Linker path CMAKE_CXX_LINKER: c:/binrev/development/vs2010/VC/bin/link.exe
但是調用NMAKE時,CMake的仍使用MinGW的鏈接:
Linking CXX shared library bin\brCore.dll
c:\binrev\development\mingw\bin\ld.exe: unrecognized option '-Wl,--enable-auto-import'
c:\binrev\development\mingw\bin\ld.exe: use the --help option for usage information
LINK failed. with 1
NMAKE : fatal error U1077: "c:\binrev\development\cmake\bin\cmake.exe": Rückgabe-Code "0xffffffff"
Stop.
NMAKE : fatal error U1077: "c:\binrev\development\vs2010\VC\BIN\nmake.exe": Rückgabe-Code "0x2"
Stop.
NMAKE : fatal error U1077: "c:\binrev\development\vs2010\VC\BIN\nmake.exe": Rückgabe-Code "0x2"
Stop.
在CMakeCache調用的bash shell腳本後MinGW的連接設置,而不是MSVC鏈接:
//Path to a program.
CMAKE_LINKER:FILEPATH=c:/binrev/development/mingw/bin/ld.exe
好,我想通我必須設置CMAKE_LINKER變量而不是CMAKE_CXX_LINKER才能獲得正確的依賴關係。但現在我又一次失敗:
Linking CXX shared library bin\brCore.dll
Das System kann die angegebene Datei nicht finden
mt.exe : general error c10100b1: Failed to load file "bin\brCore.dll". Das System kann die angegebene Datei nicht finden.
MT failed. with 31
有沒有人知道我做錯了什麼? 感謝您的幫助。
最好的問候, 地獄犬
您是否必須在MSYS shell中運行此版本?爲什麼不使用「Visual Studio命令提示符」作爲shell如果您使用MSVC編譯器並且無論如何nmake ...? – DLRdave
我已經在MSYS shell中運行它,同時我也使用它作爲GCC。我會試用VS命令promt作爲shell。 – Hellhound
我試圖通過從Visual Studio Command Promt執行cmake腳本來運行此操作,而不使用MSYS shell。同樣的效果,鏈接器試圖使用MinGW鏈接器... – Hellhound