hashlink
hashlink copied to clipboard
Unable to build C output on Windows gcc
I have compiled some code from Haxe to C, but I am unable to build it on Windows using gcc. I am using gcc installed from MSYS2's mingw-w64-x86_64-gcc package.
This is my test code:
class Main {
static function main() {
trace("Hello, world!");
}
}
This is my build.hxml:
--class-path src
--main Main
--hl out/hlc/main.c
And this is the error I get:
gcc -std=c11 -c out/hlc/main.c -o out/bin/test.o -I out/hlc -I/c/Users/nabca/Documents/src/hashlink/x64/Debug/../../src
In file included from out/hlc/main.c:6:
C:/Users/nabca/Documents/src/hashlink/src/hlc_main.c: In function 'WinMain':
C:/Users/nabca/Documents/src/hashlink/src/hlc_main.c:133:16: error: implicit declaration of function 'wmain' [-Wimplicit-function-declaration]
133 | return wmain(__argc, __argv);
| ^~~~~
I did notice that if I modify hlc_main.c so that the WinMain
and wWinMain
functions are defined after wmain
and main
, as well as change the parameters of wmain
to int argc, char *argv[]
instead of int argc, uchar *argv[]
, the code will be able to compile successfully.