尝试将Winelib与标准macOS构建工具一起使用:得到奇怪的编译器错误



我正在尝试使用Winelib在macOS上编译win32应用程序。如果可能的话,我更喜欢使用Xcode提供的标准macOS编译器。但是,到目前为止,我无法编译它。如果我尝试编译文件测试.cpp则包含以下内容:

#include <windows.h>
#include <list>
int main(int argc, char *argv[]) {
    std::list<int> blah;
    blah.push_back(1);
    return 0;
}

在 Ubuntu 16.04 上使用以下命令:

g++ -c -W -fexceptions -fshort-wchar -DWIN32 -D_DEBUG -D_WINDOWS -I/usr/include/wine-development/windows/ -I/usr/include/wine-development/msvcrt/ test.cpp

。我收到一些编译器警告,但它仍然成功编译。

但是,如果我尝试使用以下等效命令在macOS上编译相同的文件:

clang++ -c  -W -fexceptions -fshort-wchar -DWIN32 -D_DEBUG -D_WINDOWS -I/usr/local/Cellar/wine/3.0/include/wine/msvcrt -I/usr/local/Cellar/wine/3.0/include/wine/windows test.cpp

。我收到以下编译器错误,我不知道如何解决:

In file included from test.cpp:3:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/list:173:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:104:9: error: no member named 'lldiv_t' in the global namespace
using ::lldiv_t;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:110:9: error: no member named 'atoll' in the global namespace; did you
      mean 'atol'?
using ::atoll;
      ~~^
/usr/local/Cellar/wine/3.0/include/wine/msvcrt/stdlib.h:186:23: note: 'atol' declared here
__msvcrt_long __cdecl atol(const char*);
                      ^
In file included from test.cpp:3:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/list:173:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:113:9: error: no member named 'strtof' in the global namespace
using ::strtof;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:114:9: error: no member named 'strtold' in the global namespace
using ::strtold;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:117:9: error: no member named 'strtoll' in the global namespace
using ::strtoll;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:121:9: error: no member named 'strtoull' in the global namespace; did you
      mean 'strtoul'?
using ::strtoull;
      ~~^
/usr/local/Cellar/wine/3.0/include/wine/msvcrt/stdlib.h:205:24: note: 'strtoul' declared here
__msvcrt_ulong __cdecl strtoul(const char*,char**,int);
                       ^
In file included from test.cpp:3:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/list:173:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:132:9: error: no member named '_Exit' in the global namespace; did you
      mean '_exit'?
using ::_Exit;
      ~~^
/usr/local/Cellar/wine/3.0/include/wine/msvcrt/stdlib.h:179:23: note: '_exit' declared here
void          __cdecl _exit(int);
                      ^
In file included from test.cpp:3:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/list:173:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:140:9: error: no member named 'llabs' in the global namespace; did you
      mean 'labs'?
using ::llabs;
      ~~^
/usr/local/Cellar/wine/3.0/include/wine/msvcrt/stdlib.h:195:23: note: 'labs' declared here
__msvcrt_long __cdecl labs(__msvcrt_long);
                      ^
In file included from test.cpp:3:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/list:173:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:629:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/typeinfo:61:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception:82:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstdlib:145:9: error: no member named 'lldiv' in the global namespace; did you
      mean 'ldiv'?
using ::lldiv;
      ~~^
/usr/local/Cellar/wine/3.0/include/wine/msvcrt/stdlib.h:190:16: note: 'ldiv' declared here
ldiv_t __cdecl ldiv(__msvcrt_long,__msvcrt_long);
               ^
9 errors generated.

请注意,我使用的是通过自制软件安装的葡萄酒/葡萄酒库。

从表面上看,似乎 Winelib 对 msvcrt 的实现导致 Xcode 的工具链爆炸了。

我能做些什么来解决这个问题吗?

这些函数的所有声明都存在于 Wine 3.8 中。将 Wine 副本更新到版本 3.8 或更高版本,然后重试。

最新更新