我正试图在Windows 10上的MSYS2/MingGW-w64上静态链接和编译我的项目。然而,内部std库抛出了大量的编译错误,我的意思是大量的,超过2k行和200KB。我该怎么解决这个问题?
这是第一个错误块:
/mingw64/bin/g++.exe -I/home/dan9e/cartogrtist/build -I/home/dan9e/cartogrtist/src/block -I/home/dan9e/cartogrtist/src/cliParser -I/home/dan9e/cartogrtist/src/mapArt/mapArtFlat -I/home/dan9e/cartogrtist/src/mapArt/mapArtStaircase -I/home/dan9e/cartogrtist/src/palette -I/home/dan9e/cartogrtist/src/schematic -I/home/dan9e/cartogrtist/src/staircaseColumn -I/mingw64/include/GraphicsMagick -I/home/dan9e/libnbtplusplus/include -I/home/dan9e/libnbtplusplus/include/libnbtplusplus -I/home/dan9e/libnbtplusplus/include/libnbtplusplus/io -I/home/dan9e/libnbtplusplus/include/libnbtplusplus/text -I/mingw64/include/tclap -I/mingw64/include/spdlog -I/mingw64/include/fmt -g -O2 -O3 -DNDEBUG -o CMakeFiles/cartogrtist.dir/src/block/block.cpp.obj -c /home/dan9e/cartogrtist/src/block/block.cpp
In file included from C:/msys64/mingw64/include/c++/10.2.0/string:56,
from C:/msys64/mingw64/include/c++/10.2.0/bits/locale_classes.h:40,
from C:/msys64/mingw64/include/c++/10.2.0/locale:39,
from C:/msys64/mingw64/include/fmt/locale.h:11,
from C:/msys64/mingw64/include/c++/10.2.0/clocale:42,
from C:/msys64/mingw64/include/c++/10.2.0/x86_64-w64-mingw32/bits/c++locale.h:41,
from C:/msys64/mingw64/include/c++/10.2.0/bits/localefwd.h:40,
from C:/msys64/mingw64/include/c++/10.2.0/ios:41,
from C:/msys64/mingw64/include/c++/10.2.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.2.0/iostream:39,
from C:/msys64/home/dan9e/cartogrtist/src/block/block.h:19,
from C:/msys64/home/dan9e/cartogrtist/src/block/block.cpp:17:
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc: In function 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)':
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc:1484:15: error: 'ctype' does not name a type; did you mean '_wctype'?
1484 | typedef ctype<_CharT> __ctype_type;
| ^~~~~
| _wctype
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc:1485:24: error: '__ctype_type' has not been declared
1485 | typedef typename __ctype_type::ctype_base __ctype_base;
| ^~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc:1501:14: error: '__ctype_type' does not name a type; did you mean '__ctype_base'?
1501 | const __ctype_type& __ct = use_facet<__ctype_type>(___in.getloc());
| ^~~~~~~~~~~~
| __ctype_base
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc:1507:12: error: '__ct' was not declared in this scope; did you mean '__c'?
1507 | && !__ct.is(__ctype_base::space,
| ^~~~
| __c
C:/msys64/mingw64/include/c++/10.2.0/bits/basic_string.tcc:1507:20: error: '__ctype_base' is not a class, namespace, or enumeration
1507 | && !__ct.is(__ctype_base::space,
| ^~~~~~~~~~~~
其余内容可在以下网址找到:https://pastebin.com/RaiS6K75
make命令为:
dan9e@RED MINGW64 ~/cartogrtist/build
$ make -j1 1> error.log 2> error.log
为了显示正在运行的命令,在CMake中将CMAKE_VERBOSE_MAKEFILE
设置为ON
。
版本信息:
dan9e@RED MINGW64 ~/cartogrtist/build
$ g++ --version
g++.exe (Rev1, Built by MSYS2 project) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
dan9e@RED MINGW64 ~/cartogrtist/build
$ cmake --version
cmake version 3.17.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
dan9e@RED MINGW64 ~/cartogrtist/build
$ make --version
GNU Make 4.3
Built for x86_64-pc-msys
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
如果您查看包含的文件链:
In file included from C:/msys64/mingw64/include/c++/10.2.0/string:56,
from C:/msys64/mingw64/include/c++/10.2.0/bits/locale_classes.h:40,
from C:/msys64/mingw64/include/c++/10.2.0/locale:39,
from C:/msys64/mingw64/include/fmt/locale.h:11,
from C:/msys64/mingw64/include/c++/10.2.0/clocale:42,
看里面有一个CCD_ 3。这显然是不正确的,因为标准库头<clocale>
不应该包含标准库头目录之外的任何内容。
出现此问题是因为您错误地将/mingw64/include/fmt
指定为包含路径,所以文件fmt/locale.h
现在由#include "locale.h"
找到,而不应该是。
您的构建命令不应该有任何参数以/mingw64
开头的-I
开关。默认情况下,在搜索路径上启用/mingw64/include
目录。
要使用位置为/mingw64/include/fmt/format.h
的标头,请在程序中写入#include <fmt/format.h>
,因为/mingw64/include
会搜索该名称,所以会找到它。