Ubuntu Qt Cross Compilation (Raspberry Pi 2b)

Source: Internet
Author: User

Generate executable code on another platform on one platform. Why do you have to cross-compile it? In a word: It is the last resort. Sometimes it is because the target platform is not allowed or unable to install the required compiler, but also need some characteristics of the compiler, sometimes because the target platform is resource-poor, unable to run the required compiler, and sometimes because the target platform has not been established, and even the operating system is not, not to run what compiler.

To cross-compile, we need to install the corresponding cross-compilation toolchain on the host platform (compilation tool chain), then compile the source code with this cross-compilation toolchain and eventually build the code that will run on the target platform.
Common cross-compilation examples are as follows:

1. On a Windows PC, with the ADS (ARM development environment), using the ARMCC compiler, you can compile executable code for ARM CPUs.
2. On a Linux PC, using the ARM-LINUX-GCC compiler, you can compile executable code for the Linux arm platform.
3. On a Windows PC, using the Cygwin environment, run the ARM-ELF-GCC compiler to compile executable code for the ARM CPU.

First, the specific noun

Most software packages under Linux Use the Autoconf/automake tool to automatically generate makefile, as long as you use "./configure", "make", "makes install" to install the program into a Linux system. When compiling third-party source code, you can look at the Readme and install files in the project, and generally write the compilation steps.

1./configure common parameters [--build] | [--host] | [--target] | [--prefix] | [--help]

Note: Host and--host is not a mean, host is the host, that is, the platform to edit and compile the program, is a noun;--host is a verb to set the host on which the execution file runs.

>>./configure: Used to generate the corresponding Makefile;
>>--build: Perform code compilation of the host, Normal is your host system. If no value is specified using host;
>>--host: The compiled binaries are executed by the host, which prefixes the cross-compilation toolchain. This value is equal to build, because the vast majority of this is done natively if the machine is compiled. However, when cross-compiling, the build and host need to set different values, using host to specify the running host, that is, the host! = Build when the compilation is cross-compilation. If no designation will run ' config.guess ' to detect;
>>--prefix: Installation directory, such as--prefix=/usr means to install the software in/usr, the execution file will be installed in/usr/bin (instead of the default/usr/local/bin), the resource files will be installed in/usr/ Share (not the default/usr/local/share);
>>--help: View parameters;
>>--target: This parameter is special, indicating the target platform name that needs to be processed, primarily in the context of program language tools such as compilers and assembler, if no value is specified using host. Generally used to compile tools, such as to the arm Development Board to compile a can handle the MIPS program of GCC, then--target=mips;
>>>> Illustration: Compiling gcc
>>./configure--build=i386-linux--host=arm-linux--target=mipsel-linux--prefix=$ (pwd)/_install
Compile the GCC with the I386-linux compiler, the compiled GCC runs in Arm-linux, the compiled results are stored in the $ (PWD)/_install path, and the compiled GCC is used to compile the code that can be run under Mipsel-linux.

2. Makefile contains some basic pre-defined actions:

>>make: Compile source code according to makefile, connect, generate target file, executable file;
>>make clean: Clears the object file (the file with the suffix ". O") from the last make command and the executable file;
>>make Distclean: Similar to make clean, but also the configure generated files are all deleted, including makefile;
>>make test/make Check: Make is checked to ensure that no error has occurred and is normally performed before the make install;
>>make Install: Installs the successful executable file to the specified directory, generally the/usr/local/bin directory;
>>make Dist: Generates a Release package file (that is, distribution packages). This command will package the executable and related files into a tar.gz compressed file to be used as the software package for the release. It generates a file with a name similar to "package-version.tar.gz" in the current directory. Package and version are the Am_init_automake (package, version) that we define in configure.in;
>>make Distcheck: Generate and test the release package to determine the correctness of the release package. This action will automatically unpack the package file, then execute the Configure command, and do make to confirm that the compilation does not appear error, and finally prompts you that the package is ready to be released;

Third, cross-compiling source code

1. Environment
Ubuntu

2. Raspberry Pi Cross-compilation tool installation

Step1. Download Raspberry Pi Cross Compilation Tool Https://github.com/raspberrypi/tools
Step2. Place the source in a folder that can be share by each user, such as/usr/tools
Step3. Add the path of the cross-compilation tool to the environment variable, I added it to the BASHRC in order to start it later without setting it up.

Step4. Detect if the installation was successful

The following content appears

By now the cross-compilation environment has been configured to complete

Ubuntu Qt Cross Compilation (Raspberry Pi 2b)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.