From 58b120e7bf28e221fe896d6211833a82732cf782 Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Tue, 29 Jun 2021 17:54:11 +0200 Subject: [PATCH] Cross-compiling prototype --- README.md | 16 +++++++++++++++- mingw_cross_toolchain.cmake | 8 ++++++++ src/RS_images.c | 7 +++++-- src/config.h.in | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 mingw_cross_toolchain.cmake diff --git a/README.md b/README.md index 44b6654..91825d8 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,18 @@ make install On Windows system, you will probably need to specify the dependency flags for CMake. Ex: -`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.11/include" -D"ZLIB_LIBRARY=zlib/1.2.11/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" -D"PNG_LIBRARY=libpng/1.6.37/libpng.dll.a" . -G "MinGW Makefiles"` \ No newline at end of file +`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.11/include" -D"ZLIB_LIBRARY=zlib/1.2.11/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" . -G "MinGW Makefiles"` + +We can also use cross-compilation (after installing `mingw64` and `cmake` packages on your distrib): + +```shell +mkdir build && cd build +cmake -DGNU_HOST=x86_64-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake \ + -D"ZLIB_INCLUDE_DIR=zlib/1.2.11/include" \ + -D"ZLIB_LIBRARY=zlib/1.2.11/lib/libzlib.dll.a" \ + -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" \ + -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" \ + .. +cmake --build . +``` \ No newline at end of file diff --git a/mingw_cross_toolchain.cmake b/mingw_cross_toolchain.cmake new file mode 100644 index 0000000..aaf5303 --- /dev/null +++ b/mingw_cross_toolchain.cmake @@ -0,0 +1,8 @@ +SET(CMAKE_SYSTEM_NAME Windows) +IF("${GNU_HOST}" STREQUAL "") + SET(GNU_HOST i586-mingw32msvc) +ENDIF() +# Prefix detection only works with compiler id "GNU" +SET(CMAKE_C_COMPILER ${GNU_HOST}-gcc) +# CMake doesn't automatically look for prefixed 'windres', do it manually: +SET(CMAKE_RC_COMPILER ${GNU_HOST}-windres) diff --git a/src/RS_images.c b/src/RS_images.c index 71305f2..fa51456 100644 --- a/src/RS_images.c +++ b/src/RS_images.c @@ -104,8 +104,11 @@ void convert8bitsTo32bitsRGBA(unsigned char *samples_tab, PIXEL_A *pixels_tab, i void useOddBytes(unsigned char *src, PIXEL_A *dst, int size) { int i; - for(i=0; i