./../curl-7.76.1/configure --prefix=/opt/curl-7.76.1-ubuntu-x64 --with-ssl --enable-tls-srp
# 设置交叉编译工具链到环境变量
export PATH=/opt/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:$PATH
# 设置OpenSSL依赖项到环境变量
export OPENSSL_ROOT=/opt/openssl-1.1.1k-raspberrypi-armv7l
export LD_LIBRARY_PATH=$OPENSSL_ROOT/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$OPENSSL_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH
export PATH=$OPENSSL_ROOT/bin:$PATH
export CPATH=$OPENSSL_ROOT/include:$CPATH
export LIBRARY_PATH=$OPENSSL_ROOT/lib:$LIBRARY_PATH
./../curl-7.76.1/configure --host=arm-linux-gnueabihf --prefix=/opt/curl-7.76.1-raspberrypi-armv7l--with-ssl --enable-tls-srp
--host
选项,指定交叉编译工具链命令的前缀,生成的Makefile
文件中会将使用到的编译工具补全成arm-linux-gnueabihf-gcc
或者arm-linux-gnueabihf-ar
等。--with-ssl
选项,则必须先安装openssl库,。 设置环境变量,编辑/etc/profile
文件,末尾添加:
export CURL_ROOT=/opt/curl-7.76.1-ubuntu-x64
# 运行依赖
export LD_LIBRARY_PATH=$CURL_ROOT/lib:$LD_LIBRARY_PATH
# 开发依赖
export PATH=$CURL_ROOT/bin:$PATH
export CPATH=$CURL_ROOT/include:$CPATH
export LIBRARY_PATH=$CURL_ROOT/lib:$LIBRARY_PATH
export PKG_CONFIG_PATH=$CURL_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH # 需要同步修改pkgconfig目录下libcurl.pc文件中的prefix路径,指定为当前的库路径
通过CMake(cmake-gui)
构建Visual Studio
工程,然后再打开工程编译出库。此处省略一万字…
请先在系统中安装Visual Studio 6
以上版本,本机使用的是Visual Studio 2019
,在开始菜单打开所要编译的架构,如这里选择x86
:
nmake /f Makefile.vc mode=<static or dll> <options>
设如果在Windows下编译安装好了curl,使用CMake构建其他工程时,若需要依赖curl,则需要配置环境变量:
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_init
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_unbind_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_set_option
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_simple_bind_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_search_s
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_msgfree
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_err2string
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_first_entry
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_next_entry
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_first_attribute
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_next_attribute
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_get_values_len
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_value_free_len
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_get_dn
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ldap_memfree
1>libcurl.lib(ldap.obj) : error LNK2001: 无法解析的外部符号 __imp_ber_free
方案: 给工程添加依赖的库:项目右键–>属性–>配置属性–>链接器–>输入–>附加依赖项,把 ws2_32.lib
、 winmm.lib
、 wldap32.lib
添加进去。
因篇幅问题不能全部显示,请点此查看更多更全内容