I used the MingW libraries to compile an application written in C (with makefile etc.) with Ubuntu-32bit as host and Win 32/64 as the target.
Installation
sudo apt-get install mingw32 (for libraries with win32 as target ?)
sudo apt-get install mingw64 (for libraries with win64 as target ?)
Compilation
i686-w64-mingw32-gcc -o target.exe main.c // Compile for win32 target.
x86_64-w64-mingw32-gcc -o target.exe main.c // Compile for win64 target.
Since my application used makefile, I changed the variable
CC = x86_64-w64-mingw32-gcc (previously CC = gcc)
Tips
The application I was working on had a subdirectory with a bunch of c files and a makefile to compile them. Sort of a library. My first mistake was that I hadn't removed *.o files from that directory, which means compilation of appln. was showing a ton of linker errors. So I removed the *.o, *.exe from all the folders. Then I changed the gcc command in this folder's makefile, so this library could be recompiled again with this application.
Other than Ubuntu, I tried to compile this appln. using MinGW32 tools for Win7. I could get it to work to compile and install simple applications, but couldn't get mine to work. The reason was that my application compilation requires bison / flex libraries and I couldn't get it to work on MinGW32 tools for win7.
References
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://www.mingw.org/wiki/MinGW_for_First_Time_Users_HOWTO
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://mingw-w64.sourceforge.net/download.php#automated-builds
Installation
sudo apt-get install mingw32 (for libraries with win32 as target ?)
sudo apt-get install mingw64 (for libraries with win64 as target ?)
Compilation
i686-w64-mingw32-gcc -o target.exe main.c // Compile for win32 target.
x86_64-w64-mingw32-gcc -o target.exe main.c // Compile for win64 target.
Since my application used makefile, I changed the variable
CC = x86_64-w64-mingw32-gcc (previously CC = gcc)
Tips
The application I was working on had a subdirectory with a bunch of c files and a makefile to compile them. Sort of a library. My first mistake was that I hadn't removed *.o files from that directory, which means compilation of appln. was showing a ton of linker errors. So I removed the *.o, *.exe from all the folders. Then I changed the gcc command in this folder's makefile, so this library could be recompiled again with this application.
Other than Ubuntu, I tried to compile this appln. using MinGW32 tools for Win7. I could get it to work to compile and install simple applications, but couldn't get mine to work. The reason was that my application compilation requires bison / flex libraries and I couldn't get it to work on MinGW32 tools for win7.
References
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://www.mingw.org/wiki/MinGW_for_First_Time_Users_HOWTO
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
http://mingw-w64.sourceforge.net/download.php#automated-builds