Cross Compiling: Difference between revisions
No edit summary  | 
				No edit summary  | 
				||
| Line 1: | Line 1: | ||
Issues:  | Issues:  | ||
* need cross compile toolchain  | * need cross compile toolchain  | ||
** you need to find or build an entire toolchain environment; ubuntu has some, others have some, Crosstool-NG will build one from scratch  | |||
** for autotools, you typically need to define tools like ar, gcc, g++ in the build script  | |||
** for cmake, you typically need a toolchain file to specify details  | |||
* need to cross compile any dependencies (static link what you can)  | * need to cross compile any dependencies (static link what you can)  | ||
{| class="mw-collapsible mw-collapsed wikitable"  | {| class="mw-collapsible mw-collapsed wikitable"  | ||
Revision as of 19:57, 29 November 2016
Issues:
- need cross compile toolchain
- you need to find or build an entire toolchain environment; ubuntu has some, others have some, Crosstool-NG will build one from scratch
 - for autotools, you typically need to define tools like ar, gcc, g++ in the build script
 - for cmake, you typically need a toolchain file to specify details
 
 - need to cross compile any dependencies (static link what you can)
 
| libz example | 
|---|
   echo Getting source code for libraries...
   if [ ! -d zlib ]; then
       wget http://zlib.net/zlib-${zlib_version}.tar.gz
       untar zlib-${zlib_version}.tar.gz
       ln -s zlib-${zlib_version} zlib
   fi
   echo Building libraries...
   if [ "$rebuild_libs" = true ]; then
   
       export cross=arm-linux-gnueabi-
   
       # ZLIB
       cd zlib
       ./configure --prefix=${install_root}
       make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
       make install
       cd ..
   fi
 | 
| openssl example | 
|---|
   echo Getting source code for libraries...
   if [ ! -d openssl ]; then
       wget https://www.openssl.org/source/openssl-${openssl_version}.tar.gz
       untar openssl-${openssl_version}.tar.gz
       ln -s openssl-${openssl_version} openssl
   fi
   
   echo Building libraries...
   
   if [ "$rebuild_libs" = true ]; then
   
       export cross=arm-linux-gnueabi-
   
       # OPENSSL
       cd openssl
       ./Configure dist --prefix=${install_root} --openssldir=${install_root}
       make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
       make install
       cd ..
   fi
 | 
- libwebsockets example
 
- need to match the libraries on target machine for any dynamic linking requirements
 - need to match the build to the target kernel (or you might get "kernel too old")