Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) MxeExample1

 

C++98Qt CreatorLubuntu

 

MXE example 1: Hello World is an MXE example to cross-compile a Hello World program from GNU/Linux to Windows.

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppMxeExample1/CppMxeExample1.pro

 

exists(../../ConsoleApplication.pri)
{
  include(../../ConsoleApplication.pri)
}

!exists(../../ConsoleApplication.pri)
{
  QT       += core
  QT       -= gui
  CONFIG   += console
  CONFIG   -= app_bundle
  TEMPLATE = app
}

SOURCES += main.cpp

 

 

 

 

 

./CppMxeExample1/main.cpp

 

#include <iostream>

int main()
{
  std::cout << "Hello World\n";
}

/* Output when calling 'crosscompiletowindows.sh':

richel@richel-laptop:~/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Test/CppMxeExample1$ ./crosscompiletowindows.sh
Displaying cross compiler version (if it is not found, set the path to YourFolder/mxe/usr/bin
QMake version 3.0
Using Qt version 5.2.1 in /home/richel/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Libraries/mxe/usr/i686-pc-mingw32.static/qt5/lib
Cleaning up
rm: cannot remove ‘Makefile’: No such file or directory
rm: cannot remove ‘Makefile.*’: No such file or directory
rm: cannot remove ‘release’: No such file or directory
rm: cannot remove ‘debug’: No such file or directory
rm: cannot remove ‘ui_*.h’: No such file or directory
rm: cannot remove ‘qrc_*.cpp’: No such file or directory
rm: cannot remove ‘moc_*.cpp’: No such file or directory
rm: cannot remove ‘object_script*.*’: No such file or directory
rm: cannot remove ‘*.o’: No such file or directory
rm: cannot remove ‘*_plugin_import.cpp’: No such file or directory
Creating makefile
Project MESSAGE: Console application, built for Windows
Project MESSAGE: Console application, cross-compiling from Linux to Windows
Project MESSAGE: Console application, built for Windows
Project MESSAGE: Console application, cross-compiling from Linux to Windows
Project MESSAGE: Console application, built for Windows
Project MESSAGE: Console application, cross-compiling from Linux to Windows
Start make
make -f Makefile.Release
make[1]: Entering directory `/home/richel/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Test/CppMxeExample1'
i686-pc-mingw32.static-g++ -c -pipe -fno-keep-inline-dllexport -std=c++11 -Wall -Wextra -Weffc++ -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DNDEBUG -DNTRACE_BILDERBIKKEL -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I'../../Libraries/mxe/usr/i686-pc-mingw32.static/qt5/include' -I'../../Libraries/mxe/usr/i686-pc-mingw32.static/qt5/include/QtCore' -I'release' -I'../../Libraries/mxe/usr/i686-pc-mingw32.static/qt5/mkspecs/win32-g++' -o release/main.o main.cpp
i686-pc-mingw32.static-g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release/CppMxeExample1.exe release/main.o  -L/home/richel/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Libraries/mxe/usr/i686-pc-mingw32.static/qt5/lib -lQt5Core -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lz -lsicuin -lsicuuc -lsicudt -lpcre16
make[1]: Leaving directory `/home/richel/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Test/CppMxeExample1'
CppMxeExample1.pro, : SUCCESS
rm: cannot remove ‘ui_*.h’: No such file or directory
rm: cannot remove ‘qrc_*.cpp’: No such file or directory
rm: cannot remove ‘moc_*.cpp’: No such file or directory
rm: cannot remove ‘object_script*.*’: No such file or directory
rm: cannot remove ‘*.o’: No such file or directory
rm: cannot remove ‘*_plugin_import.cpp’: No such file or directory
richel@richel-laptop:~/GitHubs/richelbilderbeek/ProjectRichelBilderbeek/Test/CppMxeExample1$

*/

 

 

 

 

 

./CppMxeExample1/crosscompiletowindows.sh

 

#!/bin/sh
#From http://richelbilderbeek.nl/CppMxe.htm

#myqmake="i686-pc-mingw32.static-qmake-qt4"
myqmake="i686-pc-mingw32.static-qmake-qt5"

echo "Displaying cross compiler version (if it is not found, set the path to YourFolder/mxe/usr/bin"
$myqmake -v

for myprofile in `ls | egrep ".pro\>"`
do
  #echo $myprofile
  mybasename=`echo $myprofile | sed "s/\.pro//"`

  #echo "mybasename: "$mybasename

  echo "Cleaning up"
  rm Makefile
  rm Makefile.*
  rm -r release
  rm -r debug
  rm ui_*.h
  rm qrc_*.cpp
  rm moc_*.cpp
  rm object_script*.*
  rm *.o
  rm *_plugin_import.cpp
  rm *.exe #Also clean up the executable

  echo "Creating makefile"

  $myqmake $myprofile

  if [ ! -e Makefile ]
  then
    echo "FAIL:"$myqmake", "$myprofile": FAIL (Makefile not found)"
    continue
  fi

  echo "Start make"

  make


  if [ -e ./release/$mybasename".exe" ]
  then
    echo $myprofile", : SUCCESS"
    if [ -e ./release/$mybasename".exe" ]
    then
      cp ./release/$mybasename".exe" .
    fi
  else
    echo $myprofile", "$mytypestr": FAIL (executable not found)"
  fi

  #Cleaning up
  rm Makefile
  rm Makefile.*
  rm -r release
  rm -r debug
  rm ui_*.h
  rm qrc_*.cpp
  rm moc_*.cpp
  rm object_script*.*
  rm *.o
  rm *_plugin_import.cpp
  #rm *.exe #Keep the executable

done #next myprofile

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml