msys64使用

1. 官方网站:https://www.msys2.org/

2.清华大学镜像:https://mirror.tuna.tsinghua.edu.cn/help/msys2/

3. 常用操作:https://segmentfault.com/n/1330000004236998

 4.msys2包含mingw32和mingw64两个目录,pacman安装的时候查询的包会出来一堆,要看清楚是mingw32还是mingw64,一不小心就会安装错了

一般是用pacman -Sl cmake | grep mingw64这种命令搜索一下

 

1.cmake

windows下不能像linux下使用命令:

cmake .

这个时候会把项目生成vc的sln文件,实际上pacman安装的cmake和从cmake官方的功能是一样的,默认都是生成vc的sln文件

如果想要linux下生成Makefile文件的功能,执行cmake时要添加下面的选项

cmake -G "MinGW Makefiles" . # 这个有时候有问题
cmake -G "MSYS Makefiles" . # 这个更好一些

2.make

make安装完之后,文件名是mingw32-make.exe,要手工改成make.exe

3.gdb也需要单独安装

pacman -S mingw-w64-x86_64-gdb

4.git bash中使用gcc、make、cmake等命令

mingw64默认是不包含GUN的Toolchain的,msys2的主要作用是提供了pacman工具可以安装这些Toolchain

pacman -S mingw-w64-x86_64-toolchain

我们一般习惯使用git bash,而且他跟文件夹上下文菜单和其他工具的命令行绑定的比较好,所以我更愿意在git bash中使用gcc、make、cmake等命令

这个时候PATH中添加C:\msys64\mingw64\bin即可

5.日常开发工具

日常开发调试,要执行cmake、make、./app.exe很烦,可以自己写一个命令执行这三个命令即可

 

vs2017和vs2019是支持cmake的,但是我本地环境都报这个错误,换成mingw64的ToolChain错误是一样的

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "cmd.exe" /c ""C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="D:\git\cv\cmk\cmk04\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe"  -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\git\cv\cmk\cmk04" 2>&1"
1> Working directory: D:\git\cv\cmk\cmk04\out\build\x64-Debug
1> [CMake] -- The C compiler identification is MSVC 19.25.28612.0
1> [CMake] -- The CXX compiler identification is MSVC 19.25.28612.0
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe -- broken
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
1> [CMake]   The C compiler
1> [CMake] 
1> [CMake]     "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe"
1> [CMake] 
1> [CMake]   is not able to compile a simple test program.
1> [CMake] 
1> [CMake]   It fails with the following output:
1> [CMake] 
1> [CMake]     Change Dir: D:/git/cv/cmk/cmk04/out/build/x64-Debug/CMakeFiles/CMakeTmp
1> [CMake]     
1> [CMake]     Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_8fabf && [1/2] Building C object CMakeFiles\cmTC_8fabf.dir\testCCompiler.c.obj
1> [CMake]     [2/2] Linking C executable cmTC_8fabf.exe
1> [CMake]     FAILED: cmTC_8fabf.exe 
1> [CMake]     cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_8fabf.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~3\2019\COMMUN~1\VC\Tools\MSVC\1425~1.286\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_8fabf.dir\testCCompiler.c.obj  /out:cmTC_8fabf.exe /implib:cmTC_8fabf.lib /pdb:cmTC_8fabf.pdb /version:0.0  /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
1> [CMake]     Active code page: 65001
1> [CMake]     The system cannot find the path specified.
1> [CMake]     ninja: build stopped: subcommand failed.
1> [CMake]     
1> [CMake]     
1> [CMake] 
1> [CMake]   
1> [CMake] 
1> [CMake]   CMake will not be able to correctly generate this project.
1> [CMake] Call Stack (most recent call first):
1> [CMake]   CMakeLists.txt:6 (project)
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "D:/git/cv/cmk/cmk04/out/build/x64-Debug/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "D:/git/cv/cmk/cmk04/out/build/x64-Debug/CMakeFiles/CMakeError.log".
1> [CMake] 
1> cmd.exe /c ""C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="D:\git\cv\cmk\cmk04\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.25.28610/bin/HostX64/x64/cl.exe"  -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "D:\git\cv\cmk\cmk04" 2>&1" returned with exit code: 1

 

posted on 2020-04-05 15:42  Netsharp  阅读(4106)  评论(0编辑  收藏  举报

导航