Dear MinGW-w64 developers,
I'm trying to compile an application with MinGW as packaged with Cygwin:
mingw64-i686-gcc 4.8.3-1
mingw64-i686-binutils 2.24.0.3.85cf705-1
mingw64-i686-headers 3.3.0-1
mingw64-i686-runtime 3.3.0-1
The following simple test case:
#include <time.h> int main() { struct tm tm; _mkgmtime(&tm); }
fails to compile with the following error:
$ i686-w64-mingw32-gcc -o test.exe test.c /tmp/ccOjOHdH.o:test.c:(.text+0x16): undefined reference to `_mkgmtime' collect2: error: ld returned 1 exit status
As far as I can tell, I'm including the correct headers. I also tried the first sample application at https://msdn.microsoft.com/en-us/library/2093ets1.aspx, and it fails to link with the same error.
Interestingly, the 64-bit version of this compiler (x86_64-w64-mingw32-gcc
) appears to work fine! I suspect there is a problem with the aliasing of symbols in time.h. I can see that there are inline redirections to _mkgmtime32
/_mkgmtime64
which are only active if __CRT__NO_INLINE
is not defined, but I can't figure out how to get it undefined. Compiling with -finline
makes no difference to the error messages.
Thanks in advance for your help!
Cheers, Chris.
I have reproduced this bug on my machine, and I saw that _mkgmtime was in msvcrt on 64 bit, but not on 32 bit. msvcrt is a library that contains the C-runtime and it is linked automatically. Because of this I looked at the mingw-w64 source, and saw that mingw-w64-crt/lib64/msvcrt.def.in contains _mkgmtime, but mingw-w64-crt/lib32/msvcrt.def.in does not. This makes me think that if you add _mkgmtime and _mkgmtime32 to mingw-w64-crt/lib32/msvcrt.def.in and rebuild mingw-w64 it will fix your problem, but I haven't been able to test this.
Yes, that change does fix the link error, thanks!
This is still not working in v5.0.4. Could we simply add the symbol as suggested above? That would be really helpful.
I also had this problem using the packaged version in Ubuntu 16 LTS. mkgmtime is missing from libmsvcrt.a. I think it is fixed in later versions because I tried in Windows in msys2 using mingw-w64 i686 and it worked fine.
This was fixed in mingw-w64 v6. The fix was also back-ported to v5 but this
branch was never re-released:
https://github.com/mingw-w64/mingw-w64/commit/3b43430a378c357fcf67564d0dfd34aa1db68b48
On Mon, Mar 22, 2021 at 12:12 AM Jay Satiro raysatiro@users.sourceforge.net
wrote:
Related
Bugs: #473