Compilation with winegcc and linking with msvcrt
Hello all, I'm trying to compile a simple application like follows with winegcc, linking to msvcrt (which this test doesn't require, but it's a reduced test case): #include <stdio.h> int main() { printf("Hello"); fflush(stdout); printf(", world!\n"); return 0; } I compile it with this command: winegcc test.c -o test -lmsvcrt Looks pretty harmless, but when I run it, it only prints "Hello" and hangs on fflush. If I don't link it to msvcrt, then it doesn't hang. Why is it so? Is it a bug in Wine? Regards, Ruslan
2016-08-18 14:10 GMT-06:00 Ruslan Kabatsayev <b7.10110111(a)gmail.com>:
Hello all,
I'm trying to compile a simple application like follows with winegcc, linking to msvcrt (which this test doesn't require, but it's a reduced test case):
#include <stdio.h> int main() { printf("Hello"); fflush(stdout); printf(", world!\n"); return 0; }
I compile it with this command: winegcc test.c -o test -lmsvcrt
Looks pretty harmless, but when I run it, it only prints "Hello" and hangs on fflush. If I don't link it to msvcrt, then it doesn't hang. Why is it so? Is it a bug in Wine?
Regards, Ruslan
It's probably a conflict between msvcrt and glibc. The winegcc documentation states that the -mno-cygwin flag "is necessary for the vast majority of Win32 applications, as they typically depend on various features of MSVCRT".[1] You could also compile your program as an actual Windows EXE with `x86_64-w64-mingw32-cc test.c -o test.exe`. -Alex
On Fri, Aug 19, 2016 at 1:16 PM, Alex Henrie <alexhenrie24(a)gmail.com> wrote:
2016-08-18 14:10 GMT-06:00 Ruslan Kabatsayev <b7.10110111(a)gmail.com>:
Hello all,
I'm trying to compile a simple application like follows with winegcc, linking to msvcrt (which this test doesn't require, but it's a reduced test case):
#include <stdio.h> int main() { printf("Hello"); fflush(stdout); printf(", world!\n"); return 0; }
I compile it with this command: winegcc test.c -o test -lmsvcrt
Looks pretty harmless, but when I run it, it only prints "Hello" and hangs on fflush. If I don't link it to msvcrt, then it doesn't hang. Why is it so? Is it a bug in Wine?
Regards, Ruslan
It's probably a conflict between msvcrt and glibc. The winegcc documentation states that the -mno-cygwin flag "is necessary for the vast majority of Win32 applications, as they typically depend on various features of MSVCRT".[1] You could also compile your program as an actual Windows EXE with `x86_64-w64-mingw32-cc test.c -o test.exe`.
So I was actually linking against both msvcrt and glibc, right? This then explains everything, thanks. Replacing -lmsvcrt with -mno-cygwin fixes the issue.
participants (2)
-
Alex Henrie -
Ruslan Kabatsayev