Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when trying to cross compile for windows platform (on Linux) #413

Open
mgorges opened this issue Feb 13, 2021 · 16 comments
Open

Errors when trying to cross compile for windows platform (on Linux) #413

mgorges opened this issue Feb 13, 2021 · 16 comments
Labels

Comments

@mgorges
Copy link
Contributor

mgorges commented Feb 13, 2021

hello. Im try cross compile linux for windows platform.

checking build system type... x86_64-unknown-linux-gnu
checking host system type... i386-pc-mingw32
checking target system type... i386-pc-mingw32
checking for i386-mingw32-gcc... arg++ -g -O0 -isysroot /usr/mingw-w64-v8.0.0_gcc10.2.0/x86_64-w64-mingw32/ -DWIN32 -DWINVER=0x0501 -fcommon -I/root/.cache/lambdanative/win32/include -L/root/.cache/lambdanative/win32/lib
checking whether the C compiler works... no
configure: error: in /root/.lambdanative/tmp_install/gambc-v4_7_9': configure: error: C compiler cannot create executables See config.log' for more details

I tried various ways but I can't get it to compile. how I can help?

Originally posted by @gassechen in #389 (comment)

@mgorges mgorges changed the title Errors when trying to cross compile linux for windows platform (on Linux) Errors when trying to cross compile for windows platform (on Linux) Feb 13, 2021
@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

@gassechen can you provide more insights into a) what version of linux you are using, b) where the gcc for the win32 cross compiler is located, c) what you specified for WIN32SDK in SETUP, d) if the compiler actually runs (as in when you call the binary for gcc what do you get)?

@gassechen
Copy link

'SO version slackware64 '
'mingw-w64-v8.0.0_gcc10.2.0'
'WIN32SDK=find /usr/mingw-w64-v8.0.0_gcc10.2.0 -maxdepth 0 -print 2> /dev/null | tail -n 1
'i686-w64-mingw32-gcc -o hello.exe hello.c' works

@gassechen
Copy link

=> compiling application../usr/mingw-w64-v8.0.0_gcc10.2.0/bin/i686-w64-mingw32-gcc -g -O0 -I/root/.cache/lambdanative/win32/include -mwindows win32_microgl.c main.c icon.o -o /root/.cache/lambdanative/win32/Calculator/Calculator.exe -L/root/.cache/lambdanative/win32/lib -lpayload -lglu32 -lopengl32 -lgdi32 -lwinmm -lwsock32 -lws2_32 -lrpcrt4 -lcrypt32 -lm
/usr/mingw-w64-v8.0.0_gcc10.2.0/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: /root/.cache/lambdanative/win32/lib/libpayload.a(system.o):system.c:(.bss+0x0): multiple definition of cmd_argv'; /tmp/cce50vV1.o:main.c:(.bss+0x4): first defined here /usr/mingw-w64-v8.0.0_gcc10.2.0/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: /root/.cache/lambdanative/win32/lib/libpayload.a(system.o):system.c:(.bss+0x4): multiple definition of cmd_argc'; /tmp/cce50vV1.o:main.c:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
ERROR: failed with exit code 1
BUILD FAILED
Now complile with errors...
multiple definition of `cmd_argc';

@gassechen
Copy link

OK Calculator app for windows WORK.
this is my /targets/win32/host_linux file

win_sysroot=ls -1d ${WIN32SDK}/bin/i686-w64-mingw32-gcc | head -n 1
win_cross=ls -1 ${WIN32SDK}/bin/i686-w64-mingw32-gcc | head -n 1 | sed 's/gcc$//'
#SYS_CC=$win_cross"gcc $SYS_DEBUGFLAG -isysroot $win_sysroot -DWIN32 -DWINVER=0x0501 -fcommon -lmingw32 $cflag_additions"
#SYS_CXX=$win_cross"g++ $SYS_DEBUGFLAG -isysroot $win_sysroot -DWIN32 -DWINVER=0x0501 -fcommon -lmingw32 $cflag_additions"
SYS_CC=$win_cross"gcc $SYS_DEBUGFLAG -fcommon"
SYS_CXX=$win_cross"g++ $SYS_DEBUGFLAG -fcommon"
SYS_AR=$win_cross"ar"
SYS_RANLIB=$win_cross"ranlib"
SYS_STRIP=$win_cross"strip"
SYS_NM=$win_cross"nm"
SYS_STRIP=$win_cross"strip"
SYS_CPP=$win_cross"cpp"
SYS_AS=$win_cross"as"
SYS_LD=$win_cross"ld"
SYS_OBJCOPY=$win_cross"objcopy"
SYS_OBJDUMP=$win_cross"objdump"
SYS_READELF=$win_cross"readelf"
SYS_GPROF=$win_cross"gprof"
SYS_WINDRES=$win_cross"windres"
SYS_NM=$win_cross"nm"
SYS_EXEFIX=".exe"
SYS_APPFIX=

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

Using the previous code to auto detect thing and information from http://slackware.alienbase.nl/sbrepos/current/x86/MinGW-w64/MinGW-w64-v8.0.0_gcc10.2.0-i586-1alien.lst, the win_sysroot for your system likely should be '/usr/mingw-w64-v8.0.0_gcc10.2.0/i586-w64-mingw32' and win_cross should be '/usr/mingw-w64-v8.0.0_gcc10.2.0/bin/i586-w64-mingw32-' but that doesn't seem to be the case?

@gassechen
Copy link

Calculator Works (run in wine)
DemoHybridApp Woks (run in wine )
DemoCube Works (run in wine)
DemoSerial Work (run in wine)
If you tell me I could try a specific one.

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

Great, so you also solved the multiple definition of `cmd_argc' issue?

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

I think the difference is that your win_sysroot of /usr/mingw-w64-v8.0.0_gcc10.2.0/bin/i686-w64-mingw32-gcc is not what we'd expect, which should be something like /usr/mingw-w64-v8.0.0_gcc10.2.0/i686-w64-mingw32 ? Also isn't your sys_root a file now, not a folder?

@gassechen
Copy link

yes with -fcommon
SYS_CC=$win_cross"gcc $SYS_DEBUGFLAG -fcommon"
SYS_CXX=$win_cross"g++ $SYS_DEBUGFLAG -fcommon

I do not know what to do. comment them for now. and everything is compiling and works. It would be important if you require any specific application to test that may make use of those $cflag_additions

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

2be77d6 adds -fcommon to solve multiple definition GCC 10 issue for Linux but it seems also to be needed for cross compilation on Linux targeting win32. Will add that to master - thanks. Not sure about the win_sysroot not detecting right?

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

Your change actually doesn't use the win_sysroot at all, so that might not be the issue. a4632ca adds the -fcommon an all three host platforms.

@gassechen
Copy link

I will verify the win_sysroot usage.
the difference with http://slackware.alienbase.nl/sbrepos/current/x86/MinGW-w64/MinGW-w64-v8.0.0_gcc10.2.0-i586-1alien.lst
is that I have slackware64
this is the package https://slackware.pkgs.org/current/alienbob-x86_64/MinGW-w64-v8.0.0_gcc10.2.0-x86_64-1alien.txz.html
but they are in the same folder.

@mgorges
Copy link
Contributor Author

mgorges commented Feb 13, 2021

Sorry, I didn't find the right version file. From this listing /usr/mingw-w64-v8.0.0_gcc10.2.0/i686-w64-mingw32 and /usr/mingw-w64-v8.0.0_gcc10.2.0/bin/x86_64-w64-mingw32- would be what I would want the targets/win32/host_linux#L39 script to automatically detect, but it somehow failed to do that.?

@gassechen
Copy link

gassechen commented Feb 13, 2021

Modify the SETUP file
++ WIN64SDK = find /usr/mingw-w64-v8.0.0_gcc10.2.0 -maxdepth 0 -print 2> / dev / null | tail -n 1

make to win64 folder in / targets / win64
copy the contents of the win32 folder to / targets / win64
modify host_linux file
++ win_sysroot = ls -1d $ {WIN32SDK} / bin / x86_64-w64-mingw32-gcc | head -n 1
++ win_cross = `ls -1 $ {WIN32SDK} / bin / x86_64-w64-mingw32-gcc | head -n 1 | sed 's / gcc $ //' ''
in the configure add file the following lines

L124 - case "$ hostsys" in
++ * -mingw64 * | * -cygwin)
SYS_HOSTPLATFORM = "win64"
;;

@gassechen
Copy link

./configure Calculator win64 debug verbose
make
Works for windows7 64

@gassechen
Copy link

Modify the SETUP file
++ WIN64SDK = find /usr/mingw-w64-v8.0.0_gcc10.2.0 -maxdepth 0 -print 2> / dev / null | tail -n 1

make to win64 folder in / targets / win64
copy the contents of the win32 folder to / targets / win64
modify host_linux file
++ win_sysroot = ls -1d $ {WIN32SDK} / bin / x86_64-w64-mingw32-gcc | head -n 1
++ win_cross = `ls -1 $ {WIN32SDK} / bin / x86_64-w64-mingw32-gcc | head -n 1 | sed 's / gcc $ //' ''
in the configure add file the following lines

L124 - case "$ hostsys" in
++ * -mingw64 * | * -cygwin)
SYS_HOSTPLATFORM = "win64"
;;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants