Linux下libcurl的编译和交叉编译

1、下载curl源码

因为从github上直接clone下来的源码需要通过configure.ac 和 Makefile.am 等文件来生成configure脚本,比较麻烦。推荐直接下载curl源码,工程自带configure脚本,可以直接使用。

下载地址:https://curl.haxx.se/download/ ,此处我选择了最新的7.63.0版本。

若是从github上直接clone下来的工程,则需要对工程做如下操作:

# aclocal
# autoconf
# autoheader
# automake --add-missing

若执行automake --add-missing时遇到:required file './ltmain.sh' not found

进行libtoolize配置,然后执行automake --add-missing,生成Makefile.in文件即可。

# libtoolize --automake --copy --debug --force

参考博客:

https://blog.csdn.net/zhbpd/article/details/78179639

https://blog.csdn.net/AAA123524457/article/details/80553711

https://blog.csdn.net/caizi001/article/details/38871141

2、创建目标输出目录

我创建了两个,一个放linux版本、一个放arm版本。

# mkdir build_linux build_arm

3、在下载后解压,并进入目录,git clone下来的可省略这一步骤。

# unzip curl-7.63.0.zip
# cd curl-7.63.0

4、配置并编译

Linux版本: (--prefix指定编译输出安装路径   --enable-static 指定编译静态库)

# ./configure --prefix=/home/gec/csdn/curl/build_linux --enable-static
# make
# make install

ARM版本:(--prefix指定编译输出安装路径   --enable-static 指定编译静态库  CC指定交叉编译工具链)

# ./configure --host=arm-linux CC=arm-linux-gcc --prefix=/home/gec/csdn/curl/build_arm --enable-static
# make
# make install

更多configure配置参数可参考:

https://curl.haxx.se/docs/install.html

https://www.cnblogs.com/lidabo/p/5384018.html

5、输出结果

猜你喜欢

转载自blog.csdn.net/fangye945a/article/details/86500817