I tried to port some C/C++ code from Linux to Windows. On Linux I am using GCC-10 for building, on Windows I am trying to use MSYS2/MINGW-64. I have never used MSYS2 before and I have few experience in porting Linux/POSIX code to windows.
Most of the (Qt) code is portable anway so I got non-trivial problems only in a few code lines. The following symbols turned out to be missing:
on_exit()
O_SYNC
(used with open()
)sync()
std::at_quick_exit()
I'm not startled about 1. because it is not portable.
However 2. and 3. are POSIX symbols and 4. is part of the C++11 standard library. Since MSYS2 docs say it is POSIX and GCC compatible I would have expected these symbols to be defined.
Why are these symbols missing? Is there a way to replace the missing features (maybe using calls to the Windows API)?
I don't think MinGW ever claimed full POSIX compatibilty, so the lack of O_SYNC
and sync()
is to be expected.
on_exit
has a standard alternative std::atexit
.
Judging by the comments under this question, at_quick_exit
(and quick_exit
itself) aren't provided by msvcrt.dll
(the old Microsoft C runtime that MINGW64 uses). You can switch to the UCRT64 MSYS2 environment, which uses a more modern C runtime (ucrtbase.dll
) that does have those functions.