Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 如何使用MSYS在CMake中设置MSVC链接器_Visual Studio 2010_Cmake_Msys - Fatal编程技术网

Visual studio 2010 如何使用MSYS在CMake中设置MSVC链接器

Visual studio 2010 如何使用MSYS在CMake中设置MSVC链接器,visual-studio-2010,cmake,msys,Visual Studio 2010,Cmake,Msys,我有一个问题,迫使CMake使用MSVS链接器而不是MinGW 连接器为了在MSYS中支持MSVC,我实现了一个强制CMake的bash脚本 要使用MSVC编译器创建NMake文件,请执行以下操作: cmake-G“NMake Makefiles”-DMSVC=true-DCOMPILER\u ROOT=$COMPILER\u ROOT-DCMAKE\u PROFILE=$cmake\u PROFILE-DCMAKE\u BUILD\u TYPE=$cmake\u DEBUG-DCMAKE\u

我有一个问题,迫使CMake使用MSVS链接器而不是MinGW 连接器为了在MSYS中支持MSVC,我实现了一个强制CMake的bash脚本 要使用MSVC编译器创建NMake文件,请执行以下操作:

cmake-G“NMake Makefiles”-DMSVC=true-DCOMPILER\u ROOT=$COMPILER\u ROOT-DCMAKE\u PROFILE=$cmake\u PROFILE-DCMAKE\u BUILD\u TYPE=$cmake\u DEBUG-DCMAKE\u CXX\u LINKER=$COMPILER\u ROOT/bin/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
有人知道我做错了什么吗? 谢谢你的帮助

致以最良好的祝愿,
Hellhound

在路径问题上,这听起来像是一个经典的“同名多事物”,而“错误”的事物首先出现在路径上

如果您将带有MS工具的目录放在路径的前面,您还会遇到同样的问题吗

如果在MSYS bash提示符中键入“which link”,则环境中的第一个文件是什么

微软的工具可能对路径中具有相同名称的其他工具不太可靠。(即——可能mt.exe只是调用“link.exe”并希望它位于路径中,并没有完全限定它以确保它所需的link.exe…)类似于MSYS工具


当您在一台计算机上安装了多个开发环境时,您确实必须仔细设置构建环境,以避免出现类似的问题。

您必须在MSYS shell中运行此构建吗?如果您正在使用MSVC编译器和nmake,为什么不使用“Visual Studio命令提示符”作为shell…?我已经在MSYS shell中运行了这个命令,同时我也将它用于GCC。我将以shell的形式尝试VS命令promt。我已尝试通过从VisualStudio命令promt执行cmake脚本,在不使用MSYShell的情况下运行此命令。同样的效果,链接器尝试使用MinGW链接器。。。