You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
testmodbus-server/HowTo-Cross-Compile.md

148 lines
4.6 KiB

# Cross Compile
This manual explains the steps to prepare a basic cross compiling environment on Debian. The build will be installed to `/opt/W64-cross-compile`. If the destination folder is set up right, you do not need any root rights.
The following packages are needed:
- wine
- wine64
- mingw-w64
- mingw-w64-tools
- binutils-mingw-w64
The following sources are needed:
- [glib](https://gitlab.gnome.org/GNOME/glib)
- [atk](https://gitlab.gnome.org/GNOME/atk)
- [pango](https://gitlab.gnome.org/GNOME/pango)
- [gdk-pixbuf](https://gitlab.gnome.org/GNOME/gdk-pixbuf)
- [libepoxy](https://github.com/anholt/libepoxy)
- [GTK+](https://www.gtk.org/)
# Prepare the `cross-file.ini`
This configuration file will be needed on all meson based builds.
[host_machine]
system = 'windows'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
[properties]
c_args = []
c_link_args = []
[binaries]
c = '/usr/bin/x86_64-w64-mingw32-gcc'
cpp = '/usr/bin/x86_64-w64-mingw32-g++'
ar = '/usr/bin/x86_64-w64-mingw32-ar'
strip = '/usr/bin/x86_64-w64-mingw32-strip'
pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
windres = '/usr/bin/x86_64-w64-mingw32-windres'
ld = '/usr/bin/x86_64-w64-mingw32-ld'
exe_wrapper = 'wine64'
# lib-glib
Compile the library using the following steps.
mkdir build
cd build
meson --buildtype=release --prefix=/opt/W64-cross-compile/ --cross-file ../../cross-file.ini
mseon compile
if an error like `glib/glibconfig.h:65:51: error: missing binary operator before token "("` occures edit the line and delete the **G_GNUC_EXTENSION** expression.
meson install
Because not all compiled `*.dll` files are installed into the destination we need to copy them manualy.
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/
# atk
Compile the library using the following steps.
mkdir build
cd build
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig meson --buildtype=release --prefix=/opt/W64-cross-compile/ --cross-file ../../cross-file.ini
mseon compile
meson install
Copy manualy all compiled `*.dll` files to the destination
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/
# pango
Compile the library using the following steps.
mkdir build
cd build
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig meson --buildtype=release --prefix=/opt/W64-cross-compile/ --cross-file ../../cross-file.ini
mseon compile
meson install
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/
# gdk-pixbuf
mkdir build
cd build
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig meson --buildtype=release --prefix=/opt/W64-cross-compile/ --cross-file ../../cross-file.ini
mseon compile
meson install
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/
# libepoxy
Compile the library using the following steps.
mkdir build
cd build
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig meson --buildtype=release --prefix=/opt/W64-cross-compile/ --cross-file ../../cross-file.ini
mseon compile
meson install
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/
# GTK
## preparation beacuse of `wine`
Copy all compiled executeble and library files into the wine windows/system folder.
cp /opt/W64-cross-compile/bin/*.exe ~/.wine/drive_c/windows/system32/
cp /opt/W64-cross-compile/lib/*.dll ~/.wine/drive_c/windows/system32/
## workaround for some issues
edit the file `gdk/win32/gdkprivate-win32.h` and search around line 300 for the following declaration. The compiler is missing the **extern** statement here.
300 /* The singleton selection object pointer */
301 extern GdkWin32Selection *_win32_selection;
## compile first attempt
Configure and compile the library.
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig ./configure --prefix=/opt/W64-cross-compile/ --host=x86_64-w64-mingw32
PKG_CONFIG_PATH=/opt/W64-cross-compile/lib/pkgconfig make
make install
## fix and install the compilation
/bin/bash: Zeile 1: ../../gtk/gtk-update-icon-cache.exe: Kann die Binärdatei nicht ausführen: Fehler im Format der Programmdatei
make[3]: *** [Makefile:1673: install-update-icon-cache] Fehler 126
Edit the Makefile in demos/gtk-demos and add in line the wine prefix. Try to run the `make install`command and do the same for the next errors.
/bin/bash: Zeile 1: ../../gtk/gtk-update-icon-cache.exe: Kann die Binärdatei nicht ausführen: Fehler im Format der Programmdatei
make[5]: *** [Makefile:1184: install-update-icon-cache] Fehler 126
make[5]: Verzeichnis „/home/steffen/gtkcrosscompile/gtk+-3.24.0/demos/widget-factory“ wird verlassen
If the compilation did well copy all *.dll files into the destination.
cp `find -name "*.dll"` /opt/W64-cross-compile/lib/