mkdir gz-ws
cd gz-ws
mkdir gz-ws
cd gz-ws
libcurl HEAD
libyaml
dlfcn-win32
jsoncpp
protobuf 3.4.1
zlib
zziplib 0.13.62
freeImage 3.x
boost 1.67.0
OGRE 1.10.12 rc1
bzip2 1.0.6
TBB 4.3
Qt 5.7.0
QWT 6.1.22
ZeroMQ 4.2.3
git clone https://github.com/ignitionrobotics/ign-cmake -b ign-cmake0
git clone https://github.com/ignitionrobotics/ign-common -b ign-common1
git clone https://github.com/ignitionrobotics/ign-fuel-tools -b ign-fuel-tools1
git clone https://github.com/ignitionrobotics/ign-math -b ign-math4
git clone https://github.com/ignitionrobotics/ign-msgs -b ign-msgs1
git clone https://github.com/ignitionrobotics/ign-transport -b ign-transport4
管理员模式打开cmd,输入:
"C:\Program Files\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
或者
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
取决于你的安装版本和路径,我是后者。
cd ign-cmake
# if you want debug, run configure Debug
.\configure
nmake
nmake install
通常可以顺利Build,安装文件在gz-ws/ign-cmake/build/install/Release里面。
因为ignition后面的库依赖于不同版本的cmake,建议编译出以下几个版本,并根据不同的版本添加对应CMAKE的依赖。
cd ign-math
# if you want debug, run configure Debug
.\configure
nmake
nmake install
安装方式同理,如果报错找不到ign-cmake,则需要修改configure.bat文件,将:
..\ign-cmake\build\install\Release\ign-cmake0\lib\cmake\ignition-cmake0地址加入-DCMAKE_PREFIX_PATH。
如下:
cmake .. -G "NMake Makefiles" -DCMAKE_PREFIX_PATH="D:\Gazebo\Release" -DCMAKE_INSTALL_PREFIX="%WORKSPACE_INSTALL_DIR%"
cd ign-common
# if you want debug, run configure Debug
.\configure
nmake
nmake install
安装方式同理,但需要加入ign-cmake,ign-math和下载好的其他库路径至-DCMAKE_PREFIX_PATH。
如果仍然出现找不到某库的情况。
a)可以先运行.\configure,随后打开CMAKE GUI程序:
填写相应路径后,选择configure按钮,Optional platform那行选择x64,然后运行。
CMAKE GUI报错以后手动选择对应路径,然后选择Generate生成。
两次肯定都会失败,但是生成的配置文件可以让你在nmake命令行中成功,可以用来解决cmake文件生成有误的问题。
b)另一种方案是将已经编译好/下载好的依赖库直接复制到当前编译目录下[…/build/install/Release/…],这样对后续依赖可能产生影像,但是可以直接使用。
编译该库的时候需要先编译ign-tools,这个官方文档里面没说:
git clone https://github.com/ignitionrobotics/ign-tools
编译好后,将ign-tools和其他相应依赖加入configure.bat文件。
cd ign-fuel-tools
# if you want debug, run configure Debug
.\configure
nmake
nmake install
*如果出现以下问题:
..\bin\libcurl.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x350
这是CMakelist的失误,通过修改cmake文件如下即可解决:
…\bin\libcurl.dll
…\lib\libcurl_imp.lib
文件加载的时候未能加载到lib文件而是二进制文件,就会报出 LNK1107的错误。
这个问题在后面也可能会遇到,根据错误信息寻找相应文件即可。
出错记录:
[ 76%] Linking CXX shared library ignition-fuel_tools1.dll LINK:
command
“C:\PROGRA2\MICROS1\2017\BUILDT1\VC\Tools\MSVC\14161.270\bin\Hostx86\x64\link.exe
/nologo @CMakeFiles\ignition-fuel_tools1.dir\objects1.rsp
/out:ignition-fuel_tools1.dll /implib:ignition-fuel_tools1.lib
/pdb:D:\Gazebo\gz-ws\ign-fuel-tools\build\src\ignition-fuel_tools1.pdb
/dll /version:1.2 /machine:x64 /INCREMENTAL:NO
…\install\Release\bin\libcurl.dll
D:\Gazebo\gz-ws\ign-common\build\install\Release\lib\ignition-common1.lib
…\install\Release\lib\jsoncpp.lib …\install\Release\lib\yaml.lib
…/install/Release/lib/zip.lib …\install\Release\bin\libcurl.dll
D:\Gazebo\gz-ws\ign-math\build\install\Release\lib\ignition-math4.lib
…\install\Release\lib\jsoncpp.lib …\install\Release\lib\yaml.lib
kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST
/MANIFESTFILE:ignition-fuel_tools1.dll.manifest” failed (exit code
1107) with the following output: ClientConfig.cc.obj :
…\install\Release\bin\libcurl.dll : fatal error LNK1107: NMAKE :
fatal error U1077: ““C:\Program Files\CMake\bin\cmake.exe””:
返回代码“0xffffffff” Stop. NMAKE : fatal error U1077: ““C:\Program Files
(x86)\Microsoft Visual
Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe””:
返回代码“0x2” Stop. NMAKE : fatal error U1077: ““C:\Program Files
(x86)\Microsoft Visual
Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\nmake.exe””:
返回代码“0x2” Stop.
cd ..\..\ign-msgs
mkdir build
cd build
# if you want debug, run
..\configure Debug
..\configure
nmake
nmake install
Ign-msgs缺库或者失败可以用以上提到的方式解决。
cd ..\..\ign-transport
mkdir build
cd build# if you want debug, run ..\configure Debug..\configure
nmake
nmake install
Ign-transport必须要用修改configure.bat的方式来编译,否则后面编译gazebo的时候很容易找不到这个库。
Graphviz是不能缺的,虽然不是必须的库,但ign-common后期编译加入gazebo的时候会报错。
用nmake配置环境会报错:
[vcvarsall.bat] Environment initialized for: ‘x86_x64’
D:\Gazebo\gz-ws\graphviz\build>@set build_type=Release
D:\Gazebo\gz-ws\graphviz\build>@if not “%1”=="" set build_type=%1
D:\Gazebo\gz-ws\graphviz\build>@echo Configuring for build type
%build_type% Configuring for build type %1
D:\Gazebo\gz-ws\graphviz\build>cmake … -G “NMake Makefiles”
-DCMAKE_BUILD_TYPE="%build_type%" -DBUILD_TESTING:BOOL=False CMake Error: Error: generator : NMake Makefiles Does not match the generator
used previously: Visual Studio 16 2019 Either remove the
CMakeCache.txt file and CMakeFiles directory or choose a different
binary directory.
=所以使用CMAKE来尝试编译,结果也出错。
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find AWK (missing: AWK_EXECUTABLE)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
cmake/FindAWK.cmake:4 (find_package_handle_standard_args)
CMakeLists.txt:43 (find_package)
在CMAKE报错信息中可知,缺乏awk。
Unix和Linux自带awk,所以能直接使用,不需要另外安装。
Windows上没有带awk,需要使用GNU AWK即gawk,或其他第三方发行的awk,如nawk等。
下载gawk的地址,以及官网教程: