【QT+QGIS跨平台编译】之五:【curl+Qt跨平台编译】(一套代码、一套框架,跨平台编译)

文章目录

  • 一、curl介绍
  • 二、curl下载
  • 三、文件分析
  • 四、pro文件
  • 五、编译实践

一、curl介绍

curl(CommandLine Uniform Resource Locator)主要功能就是用不同的协议连接和沟通不同的服务器,相当封装了的socket。
libcurl支持http, https, ftp, gopher, telnet, dict, file, 和ldap 协议。libcurl同样支持HTTPS证书授权,HTTP POST, HTTP PUT, FTP 上传(当然你也可以使用PHP的ftp扩展), HTTP基本表单上传,代理,cookies和用户认证。


二、curl下载

curl网站:
libcurl
下载libcurl:
在这里插入图片描述
在这里插入图片描述
获取curl-7.86.0.tar.gz文件。


三、文件分析

解压缩curl-7.86.0.tar.gz文件。
进入curl-7.86.0/lib目录
在这里插入图片描述
CMakeLists.txt记录了要加载的文件目录、预定义项信息。

文件目录:
在这里插入图片描述
预定义项信息:
在这里插入图片描述


四、pro文件

配置config文件:

有config-win32.h、config-mac.h、config-linux.h

在这里插入图片描述
config-win32.h在文件夹下,不需修改。

基于config-mac.h,构建config-linux.h

config-linux.h文件信息:
在这里插入图片描述
在这里插入图片描述
config-mac.h文件信息:
在这里插入图片描述
在这里插入图片描述

配置头文件:

#头文件
HEADERS +=  ./altsvc.h \./amigaos.h \./arpa_telnet.h \./asyn.h \./bufref.h \./c-hyper.h \./conncache.h \./connect.h \./content_encoding.h \./cookie.h \./curl_addrinfo.h \./curl_base64.h \./curl_ctype.h \./curl_des.h \./curl_endian.h \./curl_fnmatch.h \./curl_get_line.h \./curl_gethostname.h \./curl_gssapi.h \./curl_hmac.h \./curl_krb5.h \./curl_ldap.h \./curl_md4.h \./curl_md5.h \./curl_memory.h \./curl_memrchr.h \./curl_multibyte.h \./curl_ntlm_core.h \./curl_ntlm_wb.h \./curl_path.h \./curl_printf.h \./curl_range.h \./curl_rtmp.h \./curl_sasl.h \./curl_setup.h \./curl_setup_once.h \./curl_sha256.h \./curl_sspi.h \./curl_threads.h \./curlx.h \./dict.h \./doh.h \./dotdot.h \./dynbuf.h \./easyif.h \./easyoptions.h \./escape.h \./file.h \./fileinfo.h \./fopen.h \./formdata.h \./ftp.h \./ftplistparser.h \./getinfo.h \./gopher.h \./h2h3.h \./hash.h \./headers.h \./hostip.h \./hsts.h \./http2.h \./http_aws_sigv4.h \./http_chunks.h \./http_digest.h \./http.h \./http_negotiate.h \./http_ntlm.h \./http_proxy.h \./if2ip.h \./imap.h \./inet_ntop.h \./inet_pton.h \./llist.h \./memdebug.h \./mime.h \./mqtt.h \./multihandle.h \./multiif.h \./netrc.h \./nonblock.h \./noproxy.h \./parsedate.h \./pingpong.h \./pop3.h \./progress.h \./psl.h \./quic.h \./rand.h \./rename.h \./rtsp.h \./select.h \./sendf.h \./setopt.h \./setup-vms.h \./share.h \./sigpipe.h \./slist.h \./smb.h \./smtp.h \./sockaddr.h \./socketpair.h \./socks.h \./speedcheck.h \./splay.h \./strcase.h \./strdup.h \./strerror.h \./strtok.h \./strtoofft.h \./system_win32.h \./telnet.h \./tftp.h \./timediff.h \./timeval.h \./transfer.h \./urlapi-int.h \./urldata.h \./url.h \./version_win32.h \./warnless.h \./wildcard.h \\./vauth/digest.h \./vauth/ntlm.h \./vauth/vauth.h \\./vquic/msh3.h \./vquic/ngtcp2.h \./vquic/quiche.h \./vquic/vquic.h \\./vssh\ssh.h \\./vtls/bearssl.h \./vtls/gskit.h \./vtls/gtls.h \./vtls/hostcheck.h \./vtls/keylog.h \./vtls/mbedtls.h \./vtls/mbedtls_threadlock.h \./vtls/nssg.h \./vtls/openssl.h \./vtls/rustls.h \./vtls/schannel.h \./vtls/sectransp.h \./vtls/vtls.h \./vtls/wolfssl.h \./vtls/x509asn1.h
win32 {HEADERS += ./config-win32.h
}
linux* {HEADERS += ./config-linux.h
}
macx {HEADERS += ./config-mac.h
}

配置源文件:

#源文件
SOURCES +=  ./altsvc.c \./amigaos.c \./asyn-ares.c \./asyn-thread.c \./base64.c \./bufref.c \./c-hyper.c \./conncache.c \./connect.c \./content_encoding.c \./cookie.c \./curl_addrinfo.c \./curl_des.c \./curl_endian.c \./curl_fnmatch.c \./curl_gethostname.c \./curl_get_line.c \./curl_gssapi.c \./curl_memrchr.c \./curl_multibyte.c \./curl_ntlm_core.c \./curl_ntlm_wb.c \./curl_path.c \./curl_range.c \./curl_rtmp.c \./curl_sasl.c \./curl_sspi.c \./curl_threads.c \./dict.c \./doh.c \./dynbuf.c \./easy.c \./easygetopt.c \./easyoptions.c \./escape.c \./file.c \./fileinfo.c \./fopen.c \./formdata.c \./ftp.c \./ftplistparser.c \./getenv.c \./getinfo.c \./gopher.c \./h2h3.c \./hash.c \./headers.c \./hmac.c \./hostasyn.c \./hostip4.c \./hostip6.c \./hostip.c \./hostsyn.c \./hsts.c \./http2.c \./http_aws_sigv4.c \./http.c \./http_chunks.c \./http_digest.c \./http_negotiate.c \./http_ntlm.c \./http_proxy.c \./idn_win32.c \./if2ip.c \./imap.c \./inet_ntop.c \./inet_pton.c \./krb5.c \./ldap.c \./llist.c \./md4.c \./md5.c \./memdebug.c \./mime.c \./mprintf.c \./mqtt.c \./multi.c \./netrc.c \./nonblock.c \./noproxy.c \./openldap.c \./parsedate.c \./pingpong.c \./pop3.c \./progress.c \./psl.c \./rand.c \./rename.c \./rtsp.c \./select.c \./sendf.c \./setopt.c \./sha256.c \./share.c \./slist.c \./smb.c \./smtp.c \./socketpair.c \./socks.c \./socks_gssapi.c \./socks_sspi.c \./speedcheck.c \./splay.c \./strcase.c \./strdup.c \./strerror.c \./strtok.c \./strtoofft.c \./system_win32.c \./telnet.c \./tftp.c \./timediff.c \./timeval.c \./transfer.c \./urlapi.c \./url.c \./version.c \./version_win32.c \./warnless.c \./wildcard.c \\./vauth/cleartext.c \./vauth/cram.c \./vauth/digest.c \./vauth/digest_sspi.c \./vauth/gsasl.c \./vauth/krb5_gssapi.c \./vauth/krb5_sspi.c \./vauth/ntlm.c \./vauth/ntlm_sspi.c \./vauth/oauth2.c \./vauth/spnego_gssapi.c \./vauth/spnego_sspi.c \./vauth/vauth.c \\./vquic/msh3.c \./vquic/ngtcp2.c \./vquic/quiche.c \./vquic/vquic.c \\./vssh/libssh2.c \./vssh/libssh.c \./vssh/wolfssh.c \\./vtls/bearssl.c \./vtls/gskit.c \./vtls/gtls.c \./vtls/hostcheck.c \./vtls/keylog.c \./vtls/mbedtls.c \./vtls/mbedtls_threadlock.c \./vtls/nss.c \./vtls/openssl.c \./vtls/rustls.c \./vtls/schannel.c \./vtls/schannel_verify.c \./vtls/sectransp.c \./vtls/vtls.c \./vtls/wolfssl.c \./vtls/x509asn1.c

预定义项信息:

DEFINES += BUILDING_LIBCURL USE_OPENSSL USE_LIBSSH2 USE_IPV6 HAVE_LIBSSH2_H HAVE_STRUCT_TIMEVAL
win32 {DEFINES += _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
}
linux* {DEFINES += linux
}
macx {DEFINES += macintosh __MRC__
}

依赖的库文件:

CONFIG(debug, debug|release){LIBS += -lssh2d
}else{LIBS += -lssh2
}
win32 {LIBS += -LD:/Qt/Tools/OpenSSL/Win_x64/libLIBS += -llibcrypto -llibssl -lwldap32LIBS += -lcrypt32 -luser32 -lws2_32
}
linux* {LIBS += -lcrypto -lssl
}
macx {LIBS += -L/usr/local/opt/openssl@3/libLIBS += -lcrypto -lssl
}

形成的004.curl-7.86.0.pro文件:

QT += core networkTEMPLATE = lib
CONFIG += c++17DESTDIR = ../QGISCONFIG(debug, debug|release){MOC_DIR = ../build-QGIS/curl/Debug/mocRCC_DIR = ../build-QGIS/curl/Debug/rccUI_DIR = ../build-QGIS/curl/Debug/uiOBJECTS_DIR = ../build-QGIS/curl/Debug/obj
}else{MOC_DIR = ../build-QGIS/curl/Release/mocRCC_DIR = ../build-QGIS/curl/Release/rccUI_DIR = ../build-QGIS/curl/Release/uiOBJECTS_DIR = ../build-QGIS/curl/Release/obj
}CONFIG(debug, debug|release){TARGET = curld
}else{TARGET = curl
}#DEFINES -= UNICODE
DEFINES += BUILDING_LIBCURL USE_OPENSSL USE_LIBSSH2 USE_IPV6 HAVE_LIBSSH2_H HAVE_STRUCT_TIMEVAL
win32 {DEFINES += _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE
}
linux* {DEFINES += linux
}
macx {DEFINES += macintosh __MRC__
}# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0#当前目录
INCLUDEPATH += ./ ./include ./vauth ./vquic ./vssh
#openssl路径
win32 {INCLUDEPATH += D:/Qt/Tools/OpenSSL/Win_x64/includeINCLUDEPATH += D:/Qt/Tools/OpenSSL/Win_x64/include/openssl
}
linux* {INCLUDEPATH += /opt/Qt/Tools/OpenSSL/src/includeINCLUDEPATH += /opt/Qt/Tools/OpenSSL/src/include/openssl
}
macx {INCLUDEPATH += /usr/local/opt/openssl@3/includeINCLUDEPATH += /usr/local/opt/openssl@3/include/openssl
}#SSH2路径
INCLUDEPATH += ../libssh2-1.10.0
#LIBS
LIBS += -L../QGIS
CONFIG(debug, debug|release){LIBS += -lssh2d
}else{LIBS += -lssh2
}
win32 {LIBS += -LD:/Qt/Tools/OpenSSL/Win_x64/libLIBS += -llibcrypto -llibssl -lwldap32LIBS += -lcrypt32 -luser32 -lws2_32
}
linux* {LIBS += -lcrypto -lssl
}
macx {LIBS += -L/usr/local/opt/openssl@3/libLIBS += -lcrypto -lssl
}#头文件
HEADERS +=  ./altsvc.h \./amigaos.h \./arpa_telnet.h \./asyn.h \./bufref.h \./c-hyper.h \./conncache.h \./connect.h \./content_encoding.h \./cookie.h \./curl_addrinfo.h \./curl_base64.h \./curl_ctype.h \./curl_des.h \./curl_endian.h \./curl_fnmatch.h \./curl_get_line.h \./curl_gethostname.h \./curl_gssapi.h \./curl_hmac.h \./curl_krb5.h \./curl_ldap.h \./curl_md4.h \./curl_md5.h \./curl_memory.h \./curl_memrchr.h \./curl_multibyte.h \./curl_ntlm_core.h \./curl_ntlm_wb.h \./curl_path.h \./curl_printf.h \./curl_range.h \./curl_rtmp.h \./curl_sasl.h \./curl_setup.h \./curl_setup_once.h \./curl_sha256.h \./curl_sspi.h \./curl_threads.h \./curlx.h \./dict.h \./doh.h \./dotdot.h \./dynbuf.h \./easyif.h \./easyoptions.h \./escape.h \./file.h \./fileinfo.h \./fopen.h \./formdata.h \./ftp.h \./ftplistparser.h \./getinfo.h \./gopher.h \./h2h3.h \./hash.h \./headers.h \./hostip.h \./hsts.h \./http2.h \./http_aws_sigv4.h \./http_chunks.h \./http_digest.h \./http.h \./http_negotiate.h \./http_ntlm.h \./http_proxy.h \./if2ip.h \./imap.h \./inet_ntop.h \./inet_pton.h \./llist.h \./memdebug.h \./mime.h \./mqtt.h \./multihandle.h \./multiif.h \./netrc.h \./nonblock.h \./noproxy.h \./parsedate.h \./pingpong.h \./pop3.h \./progress.h \./psl.h \./quic.h \./rand.h \./rename.h \./rtsp.h \./select.h \./sendf.h \./setopt.h \./setup-vms.h \./share.h \./sigpipe.h \./slist.h \./smb.h \./smtp.h \./sockaddr.h \./socketpair.h \./socks.h \./speedcheck.h \./splay.h \./strcase.h \./strdup.h \./strerror.h \./strtok.h \./strtoofft.h \./system_win32.h \./telnet.h \./tftp.h \./timediff.h \./timeval.h \./transfer.h \./urlapi-int.h \./urldata.h \./url.h \./version_win32.h \./warnless.h \./wildcard.h \\./vauth/digest.h \./vauth/ntlm.h \./vauth/vauth.h \\./vquic/msh3.h \./vquic/ngtcp2.h \./vquic/quiche.h \./vquic/vquic.h \\./vssh\ssh.h \\./vtls/bearssl.h \./vtls/gskit.h \./vtls/gtls.h \./vtls/hostcheck.h \./vtls/keylog.h \./vtls/mbedtls.h \./vtls/mbedtls_threadlock.h \./vtls/nssg.h \./vtls/openssl.h \./vtls/rustls.h \./vtls/schannel.h \./vtls/sectransp.h \./vtls/vtls.h \./vtls/wolfssl.h \./vtls/x509asn1.h
win32 {HEADERS += ./config-win32.h
}
linux* {HEADERS += ./config-linux.h
}
macx {HEADERS += ./config-mac.h
}#源文件
SOURCES +=  ./altsvc.c \./amigaos.c \./asyn-ares.c \./asyn-thread.c \./base64.c \./bufref.c \./c-hyper.c \./conncache.c \./connect.c \./content_encoding.c \./cookie.c \./curl_addrinfo.c \./curl_des.c \./curl_endian.c \./curl_fnmatch.c \./curl_gethostname.c \./curl_get_line.c \./curl_gssapi.c \./curl_memrchr.c \./curl_multibyte.c \./curl_ntlm_core.c \./curl_ntlm_wb.c \./curl_path.c \./curl_range.c \./curl_rtmp.c \./curl_sasl.c \./curl_sspi.c \./curl_threads.c \./dict.c \./doh.c \./dynbuf.c \./easy.c \./easygetopt.c \./easyoptions.c \./escape.c \./file.c \./fileinfo.c \./fopen.c \./formdata.c \./ftp.c \./ftplistparser.c \./getenv.c \./getinfo.c \./gopher.c \./h2h3.c \./hash.c \./headers.c \./hmac.c \./hostasyn.c \./hostip4.c \./hostip6.c \./hostip.c \./hostsyn.c \./hsts.c \./http2.c \./http_aws_sigv4.c \./http.c \./http_chunks.c \./http_digest.c \./http_negotiate.c \./http_ntlm.c \./http_proxy.c \./idn_win32.c \./if2ip.c \./imap.c \./inet_ntop.c \./inet_pton.c \./krb5.c \./ldap.c \./llist.c \./md4.c \./md5.c \./memdebug.c \./mime.c \./mprintf.c \./mqtt.c \./multi.c \./netrc.c \./nonblock.c \./noproxy.c \./openldap.c \./parsedate.c \./pingpong.c \./pop3.c \./progress.c \./psl.c \./rand.c \./rename.c \./rtsp.c \./select.c \./sendf.c \./setopt.c \./sha256.c \./share.c \./slist.c \./smb.c \./smtp.c \./socketpair.c \./socks.c \./socks_gssapi.c \./socks_sspi.c \./speedcheck.c \./splay.c \./strcase.c \./strdup.c \./strerror.c \./strtok.c \./strtoofft.c \./system_win32.c \./telnet.c \./tftp.c \./timediff.c \./timeval.c \./transfer.c \./urlapi.c \./url.c \./version.c \./version_win32.c \./warnless.c \./wildcard.c \\./vauth/cleartext.c \./vauth/cram.c \./vauth/digest.c \./vauth/digest_sspi.c \./vauth/gsasl.c \./vauth/krb5_gssapi.c \./vauth/krb5_sspi.c \./vauth/ntlm.c \./vauth/ntlm_sspi.c \./vauth/oauth2.c \./vauth/spnego_gssapi.c \./vauth/spnego_sspi.c \./vauth/vauth.c \\./vquic/msh3.c \./vquic/ngtcp2.c \./vquic/quiche.c \./vquic/vquic.c \\./vssh/libssh2.c \./vssh/libssh.c \./vssh/wolfssh.c \\./vtls/bearssl.c \./vtls/gskit.c \./vtls/gtls.c \./vtls/hostcheck.c \./vtls/keylog.c \./vtls/mbedtls.c \./vtls/mbedtls_threadlock.c \./vtls/nss.c \./vtls/openssl.c \./vtls/rustls.c \./vtls/schannel.c \./vtls/schannel_verify.c \./vtls/sectransp.c \./vtls/vtls.c \./vtls/wolfssl.c \./vtls/x509asn1.c# Default rules for deployment.
#unix {
#    target.path = /usr/lib
#}
#!isEmpty(target.path): INSTALLS += target

五、编译实践

用QtCreator程序,打开004.curl-7.86.0.pro文件。

在这里插入图片描述

在windows下编译,形成:
在这里插入图片描述
在linux下编译,形成:
在这里插入图片描述
在macos下编译,形成:
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/423050.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Conda python管理环境environments 四 从入门到精通

Conda系列: 翻译: Anaconda 与 miniconda的区别Miniconda介绍以及安装Conda python运行的包和环境管理 入门Conda python管理环境environments 一 从入门到精通Conda python管理环境environments 二 从入门到精通Conda python管理环境environments 三 从入门到精通…

Linux--文件链接

目录 1.建立软连接 2.建立硬链接 3.什么是软链接 Linux中软链接的应用场景 4.什么是硬链接 5.文件与目录的硬链接数 6.软链接与硬链接的区别 用户无法对目录建立硬链接,可以建立软连接。 在Linux中文件的链接有两种:1.软连接 2.硬链接 1.建立软…

c++学习第十一讲---文件操作

文件操作&#xff1a; c中对文件操作需要包含头文件 < fstream > 文本文件&#xff1a;以ASCII码形式储存 二进制文件&#xff1a;以二进制文件储存&#xff08;读不懂&#xff09; 操作文件三大类&#xff1a; 读&#xff1a;ifstream ; 写&#xff1a;ofstream ; 读…

NodeJs 第二十一章 模版引擎

模板引擎是一种用于生成动态网页的工具。它将静态的模板文件与动态的数据源相结合&#xff0c;生成最终的网页。模板引擎通常用于Web开发中&#xff0c;可以方便地将数据动态地插入到页面中&#xff0c;从而生成具有动态内容的网页。 模板引擎的核心功能是数据绑定和逻辑控制。…

GPT-4 的决策在股市中进行量化投资

论文题目:Can Large Language Models Beat Wall Street? Unveiling the Potential of AI in Stock Selection 论文链接:https://arxiv.org/abs/2401.03737 博客地址:https://www.marketsense-ai.com/ 从本质上来说&#xff0c;股票选择是个价格发现机制&#xff0c;在股票投…

JAVA:OFD Reader Writer 开源库技术解析

1、简述 OFD Reader & Writer 是一个由开源社区推动的 OFD 文件处理库&#xff0c;它旨在提供对 OFD 格式文件的读取和写入功能。这一开源项目为开发者提供了强大而灵活的工具&#xff0c;使得在应用程序中处理和生成 OFD 文件变得更加容易和高效 开源地址&#xff1a;htt…

【开源】基于JAVA语言的新能源电池回收系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 用户档案模块2.2 电池品类模块2.3 回收机构模块2.4 电池订单模块2.5 客服咨询模块 三、系统设计3.1 用例设计3.2 业务流程设计3.3 E-R 图设计 四、系统展示五、核心代码5.1 增改电池类型5.2 查询电池品类5.3 查询电池回…

【江科大】STM32:定时器中断

文章目录 TIM&#xff08;Timer&#xff09;定时器根据复杂度和应用场景分为了高级定时器、通用定时器、基本定时器三种类型基本定时器通用定数器 高级定时器 时钟&#xff08;时钟电路&#xff09;的作用是什么&#xff1a;设置定时器触发中断普通方法&#xff1a;预分频器时序…

《WebKit 技术内幕》学习之九(2): JavaScript引擎

2 V8引擎 2.1 基础 V8是一个开源项目&#xff0c;也是一个JavaScript引擎的实现。它最开始是由一些语言方面的专家设计出来的&#xff0c;后被Google收购&#xff0c;成为了JavaScript引擎和众多相关技术的引领者。其目的很简单&#xff0c;就是为了提高性能。因为在当时之前…

FastDFS分布式文件存储

为什么会有分布式文件系统&#xff1f; 分布式文件系统是面对互联网的需求而产生。因为互联网时代要对海量数据进行存储。很显然靠简单的增加硬盘个数已经满足不了我们的要求。因为硬盘传输速度有限但是数据在急剧增长&#xff0c;另外我们还要要做好数据备份、数据安全等。采用…

Vue2中CesiumV1.113.0加载离线地图

Vue2中CesiumV1.113.0加载离线地图&#xff0c;本文以天地图为例。 1.使用nodejs获取天地图 新建nodejsdownmap项目文件夹&#xff0c;初始化项目 npm init -y src/index.js // An highlighted block var Bagpipe require(bagpipe) var fs require("fs"); var r…

Kafka-服务端-日志存储

基本概念 首先需要了解的是&#xff0c;Kafka使用日志文件的方式保存生产者发送的消息。每条消息都有一个offset值来表示它在分区中的偏移量&#xff0c;这个offset值是逻辑值&#xff0c;并不是消息实际存放的物理地址。 offset值类似于数据库表中的主键&#xff0c;主键唯一…