Outils pour utilisateurs

Outils du site


tech:notes_cross-compilation

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
tech:notes_cross-compilation [2025/11/13 19:26] Jean-Baptistetech:notes_cross-compilation [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon}}
 +
 +# Notes cross-compilation
 +
 +
 +Voir : 
 +https://blog.svgames.pl/article/cross-compiling-c-programs-for-ms-windows-using-mingw
 +
 +
 +~~~bash
 +apt-get install crossbuild-essential-i386
 +~~~
 +
 +Ou 
 +~~~bash
 +cat /etc/apt/sources.list | grep debian | sed -e 's/stretch/jessie/g' | grep -v deb-src > /etc/apt/sources.list.d/jessie.list
 +
 +dpkg --add-architecture i386
 +apt-get update
 +
 +apt-get install mingw32 mingw32-binutils
 +#apt-get install mingw-w64
 +~~~
 +
 +`plop.cpp`
 +~~~cpp
 +#include <iostream>
 +
 +int main(int argc, char** argv)
 +{
 +    std::cout << "Hello" << std::endl;
 +    return 0;
 +}
 +~~~
 +
 +
 +~~~bash
 +i586-mingw32msvc-g++ -o plop.exe plop.cpp
 +~~~
 +
 +On windows error libstdc++-6.dll missing
 +
 +Pour le plus avoir l'erreur \\
 +Nous ne voulons plus de DLL, donc mettons tout en static
 +
 +~~~bash
 +i586-mingw32msvc-g++ -o plop.exe plop.cpp
 +~~~
 +
 +~~~bash
 +aptitude search '~n curl ~r i386'
 +
 +apt-get source curl:i386
 +apt-get source libcurl3:i386 libcurl3-gnutls:i386
 +cd curl
 +
 +#apt-get install crossbuild-essential-i386
 +
 +export ARCH=i386 CROSS_COMPILE=arm-linux
 +~~~
 +
 +
 +~~~bash
 +make -f lazy_makefile CC=i686-w64-mingw32-gcc
 +./configure --host=i686-w64-mingw32 --enable-shared --disable-install-doc
 +./configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 
 +./configure --host=x86_64-w64-mingw32 --disable-magic --disable-cuckoo --with-crypto CFLAGS=-I/root/openssl/include LDFLAGS=-L/root/openssl/lib --enable-static
 +
 +The right way to do this is to add the `-static` flag to an `LDFLAGS` variable. For all targets: `AM_LDFLAGS=-static`
 +
 +export CC=i586-mingw32msvc-cc
 +./configure --host=i686-w64-mingw32 --enable-static
 +
 +export CFLAGS='-static'
 +
 +make V=1 curl_LDFLAGS=-all-static
 +
 +
 +git clone -b curl-tiny-7.72 https://github.com/curl/curl.git
 +~~~
 +
 +~~~
 +libtool:   error: Could not determine the host path corresponding to
 +libtool:   error:   '/home/jibe/code/i386/curl-7.52.1/lib/.libs'
 +libtool:   error: Continuing, but uninstalled executables may not work.
 +libtool:   error: Could not determine the host path corresponding to
 +libtool:   error:   '/home/jibe/code/i386/curl-7.52.1/lib/.libs:/usr/local/lib:/usr/local/bin'
 +libtool:   error: Continuing, but uninstalled executables may not work.
 +make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/src'
 +make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/src'
 +Making all in include
 +make[1]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include'
 +Making all in curl
 +make[2]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include/curl'
 +make  all-am
 +make[3]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include/curl'
 +make[3]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include/curl'
 +make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include/curl'
 +make[2]: Entering directory '/home/jibe/code/i386/curl-7.52.1/include'
 +make[2]: Nothing to be done for 'all-am'.
 +make[2]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include'
 +make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1/include'
 +make[1]: Entering directory '/home/jibe/code/i386/curl-7.52.1'
 +make[1]: Nothing to be done for 'all-am'.
 +make[1]: Leaving directory '/home/jibe/code/i386/curl-7.52.1'
 +~~~
 +
 +~~~
 +$ find . -iname curl.exe
 +./curl-7.52.1/src/.libs/curl.exe
 +./curl-7.52.1/src/curl.exe
 +~~~
 +
 +Le bon est celui qui est dans `src/.libs/`
 +
 +
 +~~~bash
 +export AM_LDFLAGS='-static'
 +
 +git clone https://github.com/curl/curl.git
 +cd curl
 +git tag
 +git checkout curl-7_9_8
 +
 +export ROOTDIR="${PWD}"
 +cd curl
 +#$ export CROSS_COMPILE="arm-none-linux-gnueabi"
 +#export CROSS_COMPILE="stable-i686-pc-windows-gnu"
 +export CROSS_COMPILE="i686-w64-mingw32"
 +#export CPPFLAGS="-I${ROOTDIR}/openssl/include -I${ROOTDIR}/zlib/include"
 +export CPPFLAGS="-I${ROOTDIR}/openssl/include/openssl -I${ROOTDIR}/openssl/include/crypto -I${ROOTDIR}/openssl/include/internal"
 +export LDFLAGS="-L${ROOTDIR}/openssl/libs -L${ROOTDIR}/zlib/libs"
 +export AR=${CROSS_COMPILE}-ar
 +export AS=${CROSS_COMPILE}-as
 +export LD=${CROSS_COMPILE}-ld
 +export RANLIB=${CROSS_COMPILE}-ranlib
 +export CC=${CROSS_COMPILE}-gcc
 +export NM=${CROSS_COMPILE}-nm
 +export LIBS="-lssl -lcrypto"
 +./buildconf
 +./configure --prefix=${ROOTDIR}/build --target=${CROSS_COMPILE} --host=${CROSS_COMPILE} --build=i586-pc-linux-gnu --with-ssl --with-zlib
 +~~~
 +
 +~~~bash
 +sudo apt-get build-dep curl
 +~~~
 +
 +
 +## Pb
 +
 +### Err
 +
 +`m32test.c`
 +~~~c
 +#include <stdio.h>
 +int main()
 +{
 +   printf("This works\n");
 +   return 0;
 +}
 +~~~
 +
 +~~~
 +$ gcc -m32 -o m32test m32test.c
 +In file included from /usr/include/stdio.h:27:0,
 +                 from m32test.c:2:
 +/usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory
 + #  include <sys/cdefs.h>
 +                         ^
 +compilation terminated.
 +~~~
 +
 +~~~
 +# gcc -m32 -o m32test m32test.c                                                                                                                                              
 +In file included from m32test.c:1:                                                                                                                                                            
 +/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
 + #include <bits/libc-header-start.h>                                                                                                                                              
 +          ^~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                         
 +compilation terminated.
 +~~~
 +
 +Solution
 +~~~bash
 +apt-get install gcc-multilib
 +~~~
 +
 +
 +### Err undefined reference to
 +
 +Pb linking error
 +
 +https://stackoverflow.com/questions/50471481/how-to-cross-compile-from-linux-to-32-bit-windows-executable
 +
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki