Неllо еvеrybоdу!
I try to compile program with MinGW on Linux:
i686-w64-mingw32-g++ -static -mwindows ./obj/CFLF.o ./obj/resources.o -o ./bin/CFLF.exe
and catch this output:
./mingw-w64-crt/crt/crtexe.c:171: multiple definition of `WinMainCRTStartup'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/../../../../i686-w64-
mingw32/lib/../lib/crt2.o:./mingw-w64-crt/crt/crtexe.c:171: first
defined here
./obj/CFLF.o: In function `mainCRTStartup':
./mingw-w64-crt/crt/crtexe.c:199: multiple definition of `mainCRTStartup'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/../../../../i686-w64-
mingw32/lib/../lib/crt2.o:./mingw-w64-crt/crt/crtexe.c:199: first
defined here
./obj/CFLF.o:cygming-crtbegin.c:(.text+0x500): multiple definition of `__gcc_register_frame'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/crtbegin.o:cygming-crtbegin.c:
(.text+0x0): first defined here
./obj/CFLF.o:cygming-crtbegin.c:(.text+0x560): multiple definition of __gcc_deregister_frame'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/crtbegin.o:cygming-crtbegin.c:
(.text+0x60): first defined here
./obj/CFLF.o:crtexe.c:(.CRT+0x10): multiple definition of `mingw_pcinit'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/../../../../i686-w64-
mingw32/lib/../lib/crt2.o:./mingw-w64-crt/crt/crtexe.c:118: first
defined here
./obj/CFLF.o:crtexe.c:(.data+0x0): multiple definition of `__mingw_winmain_nShowCmd'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/../../../../i686-w64-
mingw32/lib/../lib/crt2.o:./mingw-w64-crt/crt/crtexe.c:118: first
defined here
./obj/CFLF.o:crtexe.c:(.CRT+0x4): multiple definition of `mingw_pcppinit'
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/../../../../i686-w64-
mingw32/lib/../lib/crt2.o:./mingw-w64-crt/crt/crtexe.c:118: first
defined here
/usr/lib/gcc/i686-w64-mingw32/6.2-win32/crtbegin.o:cygming-crtbegin.c:
(.text+0x22): undefined reference to `_Jv_RegisterClasses'
Why? My code's point is WinMain, not WinMainCRTStartup or mainCRTStartup.
I write link to code, because is so big (GitHub).
P.S.: I compile this code with MinGW on Windows and hasn't this errors. P.P.S.: Why I not use Windows? Just for base education.
The problem is that you don't create object files, but executable files that you then attempt to link together.
The command
i686-w64-mingw32-g++ ./src/main.cpp ./src/downloader.cpp -o ./obj/CFLF.o -lwinhttp
should really be
i686-w64-mingw32-g++ ./src/main.cpp -c -o ./obj/main.o
That will create the object file ./obj/main.o
that you in a later stage use for the actual linking. The three big differences is that you don't provide multiple source files, you use the -c
option will tells the GCC frontend program to only compile into object files, and you don't provide a library (which is only used when linking).
This needs to be done for all source files.
Then you can link all the object files together:
i686-w64-mingw32-g++ ./obj/main.o ./obj/downloader.o ./obj/resources.o -o ./bin/CFLF.exe -lwinhttp