简体   繁体   中英

Trying to use Winelib with standard macOS build tools: getting strange compiler errors

I'm trying to compile a win32 application on macOS using Winelib. I'd prefer to use the standard macOS compiler provided with Xcode if at all possible. However, so far I'm not able to get it to compile. If I try to compile the file test.cpp with the following contents:

#include <windows.h>
#include <list>

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

on Ubuntu 16.04 using the following command:

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

... I get a few compiler warnings but it still compiles successfully.

However, if I try to compile the same file on macOS with the following equivalent command:

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

...I get the following compiler errors that I have no idea how to fix:

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.

Note that I am using wine / winelib installed via homebrew.

From the looks of things, it seems that Winelib's implementation of msvcrt causes Xcode's toolchain to blow up.

Is there anything I can do to fix this?

All of the declarations for these functions are present as of Wine 3.8. Update your copy of Wine to version 3.8 or later and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM