无法使用Qt Creator在Windows中构建yaml-cpp

Unable to build yaml-cpp in Windows using Qt Creator

本文关键字:Windows 构建 yaml-cpp Creator Qt      更新时间:2023-10-16

我正在尝试使用Qt Creator和MinGW 64位工具包在Windows 10中构建yaml-cpp。我正在使用yaml-cpp主存储库,以防有人想知道。

当我试图在Qt Creator中构建它时,我得到了这个错误:

C:Program FilesCMakesharecmake-3.16ModulesCMakeMinGWFindMake.cmake:12: error: sh.exe was found in your PATH, here: C:/devkitPro/msys/bin/sh.exe For MinGW make to work correctly sh.exe must NOT be in your path. Run cmake from a shell that does not have sh.exe in your PATH. If you want to use a UNIX shell, then use MSYS Makefiles. CMakeLists.txt:3 (project)

我还在Qt Creator中使用Windows Sandbox(模拟新的Windows安装(尝试了同样的操作,但出现了以下错误:

C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestsrcgtest-death-test.cc:637: error: 'AutoHandle' does not name a type; did you mean 'LocalHandle'?
AutoHandle write_handle_;
^~~~~~~~~~
LocalHandle
C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestincludegtestinternalgtest-port.h:1782: error: 'AutoHandle' does not name a type; did you mean 'mutable'?
AutoHandle thread_;
^~~~~~~~~~
mutable
C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestsrcgtest-death-test.cc:656: error: 'child_handle_' was not declared in this scope
const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
^~~~~~~~~~~~~
C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestsrcgtest-death-test.cc:670: error: 'write_handle_' was not declared in this scope
write_handle_.Reset();
^~~~~~~~~~~~~
C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestsrcgtest-death-test.cc:720: error: 'write_handle_' was not declared in this scope
write_handle_.Reset(write_handle);
^~~~~~~~~~~~~
C:UsersWDAGUtilityAccountDocumentsyaml-cpp-mastertestgtest-1.8.0googletestsrcgtest-death-test.cc:777: error: 'child_handle_' was not declared in this scope
child_handle_.Reset(process_info.hProcess);
^~~~~~~~~~~~~

在Windows Sandbox中完成的这些错误太多了,我无法将它们全部列出,大约有33个(其中一些是相同错误的重复(。当我在Ubuntu或任何GNU/Linux发行版中构建yaml-cpp时,这种情况都不会发生,并且构建得几乎完美而没有任何问题。

那么,为什么这些错误只出现在Windows中,而不出现在Ubuntu中呢?

当我尝试使用MSVC 2017 64位工具包在Qt Creator中构建yaml-cpp时,出现了以下错误:

C:TempAMEyaml-cpptestgtest-1.8.0googletestincludegtestinternalgtest-port.h:996: error: C2220: warning treated as error - no 'object' file generated

我真的很困惑到底发生了什么,为什么它只在GNU/Linux发行版中工作,为什么它不能在Windows中构建?有没有任何方法可以使用QtCreator在Windows中构建yaml-cpp?

好的!我已经解决了问题!

我所需要做的就是从环境变量中的系统路径中删除C:/devkitPro/msys/bin/,然后在YAML-CPP的Qt项目构建设置中禁用YAML_CPP_BUILD_TESTS,就成功了!

出于某种原因,GTest(谷歌测试框架(没有在MinGW中构建,这就是它出现错误的原因。