I am trying to create a executable file works on Windows 64bit from linux.
I am using MXE to cross compile c file on my ubuntu server. And after I compile c file to .exe file, I move the file to my desktop(windows 10 64bit).
Here's what I did.
installed mingw-w64
sudo apt-get install mingw-w64sudo apt-get install gcc-mingw-w64I cloned the mxe git and set some attrs.
git clone https://github.com/mxe/mxe.gitcd mxeecho MXE_TARGETS=x86_64-w64-mingw32.static > settings.mkmake ccecho 'export PATH="$PATH:$HOME/mxe/usr/bin"' >> ~/.bash_profileI created c file for test.
cat<<'EOT' > test.c #include <stdio.h> void main() { printf("Hello World\n"); } EOTI compiled c file to exe file.
x86_64-w64-mingw32-gcc -o test.exe test.c
Finally I could get an exe file that I compiled by wingw, but when I try to open this file on my desktop Windows 10, it won't work. There's only a short blink when I open this exe file.
I tried x86_64-w64-mingw32.static-gcc to compile the file, but won't work.
x86_64-w64-mingw32.static-gcc: command not found
If you don't get an error, it probably works.
You created a console application, so it will open a console window, print to it and when the program finishes the console window will close. That's the short blink you're seeing.
Open a Command Prompt or PowerShell window and run your
test.exefrom there. Type the full path totest.exe, or dragtest.exeon the console window and press Enter. When the program exits, the console will remain open and you will see the output of your application.