curl cross compile

environment

  • ubuntu 18.04 64bit
  • curl 7.87.0
  • arm -linux-gnueabihf

Practical

Go to the official website to download the latest compressed package version 7.87.0, https://curl.se/download.html , and then unzip it

 tar xvf curl-7.87.0.tar.gz cd curl-7.87.0

Next, prepare the cross-compilation tool chain, which is generally provided by the solution manufacturer. For example, I use /usr/local/linaro/gcc- arm -8.3-2019.03-x86_64- arm -linux-gnueabihf/ , its The directory structure is similar to the following

In order to find the corresponding compilation command in the shell , you need to modify the system environment variable PATH

 export PATH=/usr/local/linaro/gcc- arm -8.3-2019.03-x86_64- arm -linux-gnueabihf/bin:$PATH

After setting, it will take effect immediately, and it is valid once. If you want to be effective for a long time, you can add the above export statement to the end of the ~/.bashrc file

Finally, to verify the environment, execute the command arm-linux-gnueabihf-gcc -v

Next, start compiling curl

 ./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=/usr/local/linaro/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --prefix=/home/longjing/xgx/curl-7.87.0/build make make install

in,

  • --target refers to the target platform for cross compilation
  • --host refers to which platform to run after compiling
  • --prefix refers to the directory where the compiled files are stored, such as executable files, static/dynamic library files, etc.
  • CC means cross compiler

configure can add many features, and you can add them according to your actual situation. After the compilation is complete, the directory structure of the build folder is like this

At this time, if you want to use the curl executable program on the development board of the corresponding solution, you can directly run bin/curl ; if you want to make an upper-level application based on curl , you can put the include and lib folders in your own project.

This article is transferred from https://xugaoxiang.com/2023/01/10/curl-arm-cross-compile/
This site is only for collection, and the copyright belongs to the original author.