目录
山不在高,有仙则名。水不在深,有龙则灵。 ----CSDN 时时三省
山不在高,有仙则名。水不在深,有龙则灵。 ----CSDN 时时三省
1,需要的安装软件
vscode (community 版本)版本如下:
下载官网:
下载 Visual Studio Tools - 免费安装 Windows、Mac、Linux
我下载的如图所示:
备注:
使用蓝色图标的 VSCODE ,这个我没配成功。
vscode 安装后,还需要安装 工作负荷 及 单个组件如下:
报错1:
CMake Error at CMakeLists.txt:3 (project):
Failed to run MSBuild command:
MSBuild.exe
to get the value of VCTargetsPath:
Configuring incomplete, errors occurred!
如果上面的工作负荷以及单个组件未安装,则会报这个错,
报错2:
CMake Error at C:/opt/ros/melodic/x64/share/catkin/cmake/all.cmake:116 (project):
Failed to run MSBuild command:
MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R) Build Engine Version 2.0.50727.9031
[Microsoft .NET Framework, Version 2.0.50727.9044]
Copyright (C) Microsoft Corporation 2005. All rights reserved
E:\Work\share\CMakeFiles\3.10.0\VCTargetsPath.vcxproj(3,13): error MSB4066: 无法识别元素 <ItemGroup> 中的属性“Label”。
如果报上面这个错,则需要添加环境变量(路径根据 MSBuild 的安装位置而定):
E:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin
cmake 安装包
安装完后,要把 相应的 bin 路径添加至 环境变量
下载官网:
点击下图位置下载:
git for window 安装包
安装完后,要把 相应的 bin 路径添加至 环境变量
下载官网:
下载下图中的安装包,一键安装
mingw 编译套件
安装完后,要把 相应的 bin 路径添加至 环境变量
下载路径:
【免费】mingw64.zip_mingw免安装版,mingw64免安装资源-CSDN文库
下载解压后,不需要安装,把 bin 路径添加至 环境变量即可
环境变量添加如下:
2,执行
编写相应的 CMakeLists.txt.
新建一个 build 目录,因为在编译过程中会有中间文件,所以在 build 目录下执行以下命令,即可产生适用于winds的可执行文件
cmake -G "Visual Studio 17 2022" ..
cmake --build ./ --config Release
build目录下产生以下文件,在 Release 目录里面,双击.exe文件,即可执行