libcurl linux 静态链接库_Linux ubuntu OpenSSL + curl 静态库编译及使用
下载源码
源码编译
解压之后,进入源码目录openssl-1.1.0f,执行如下命令。因为只需要编译静态库,也没有特殊要求,所以使用的编译选项配置很简单:
./config -fPIC no-shared --prefix=/home/aa/Downloads/linux
make all
make install
--prefix 用来指定输出目录 ,-fPIC:指示生成位置无关的代码,这个选项是在把openssl生成的静态库链接到动态库的时候提示错误添加的;no-shared:指示生成静态库。
最终在指定目录下会编译出libssl.a和libcrypto.a两个库文件,在开发的时候只需要包含头件并链接这两个库就可以了。
附录:
关于openssl的编译选项的解读:
全局选项
第一类是全局性选项:
--openssldir=OPENSSLDIR 安装目录,默认是 /usr/local/ssl 。
--prefix=PREFIX 设置 lib include bin 目录的前缀,默认为 OPENSSLDIR 目录。
--install_prefix=DESTDIR 设置安装时以此目录作为"根"目录,通常用于打包,默认为空。
zlibzlib-dynamicno-zlib 使用静态的zlib压缩库、使用动态的zlib压缩库、不使用zlib压缩功能。
threadsno-threads 是否编译支持多线程的库。默认支持。
sharedno-shared 是否生成动态连接库。
asmno-asm 是否在编译过程中使用汇编代码加快编译过程。
enable-sse2no-sse2 启用/禁用SSE2指令集加速。如果你的CPU支持SSE2指令集,就可以打开,否则就要关闭。
gmpno-gmp 启用/禁用GMP库
rfc3779no-rfc3779 启用/禁用实现X509v3证书的IP地址扩展
krb5no-krb5 启用/禁用 Kerberos 5 支持
sslno-sslssl2ssl3no-ssl2no-ssl3tlsno-tls 启用/禁用 SSL(包含了SSL2/SSL3) TLS 协议支持。
dsono-dso 启用/禁用调用其它动态链接库的功能。[提示]no-dso仅在no-shared的前提下可用。
[提示]为了安装Apache的mod_ssl成功,SSLv2/SSLv3/TLS都必须开启。
算法选项
第二类用于禁用crypto目录下相应的子目录(主要是各种算法)。虽然理论上这些子目录都可以通过"no-*"语法禁用,但是实际上,为了能够最小安装libcrypto,libssl,openssl,其中的大部分目录都必须保留,实际可选的目录仅有如下这些:
no-md2,no-md4,no-mdc2,no-ripemd 这些都是摘要算法,含义一目了然。
no-des,no-rc2,no-rc4,no-rc5,no-idea,no-bf,no-cast,no-camellia 这些都是对称加密算法,含义一目了然。"bf"是"Blowfish"的意思。
no-ec,no-dsa,no-ecdsa,no-dh,no-ecdh 这些都是不对称加密算法,含义一目了然。
no-comp 数据压缩算法。因为目前实际上并没有压缩算法,所以只是定义了一些空接口。
no-store 对象存储功能。
CURL
1.下载,解压;进入目录;将上面openssl 输出的整个目录,命名 openssl 拷贝到 curl 目录下;
2.编译:
./configure --prefix=/home/aa/Downloads/linux --with-ssl=$(pwd)/openssl --disable-shared
./configure --prefix=/home/program/linux/libs --with-ssl=/usr/local/openssl --disable-shared
--prefix指定输出目录;--with-ssl=./openssl 指定 openssl 目录;
make all
make install
openssl静态库libcrypto.a和libssl.a出现undefined reference to错误的问题
libs/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'libs/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':dso_dlfcn.c:(.text+0x334): undefined reference to `dlsym'dso_dlfcn.c:(.text+0x3f2): undefined reference to `dlerror'libs/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':dso_dlfcn.c:(.text+0x459): undefined reference to `dlopen'dso_dlfcn.c:(.text+0x4c9): undefined reference to `dlclose'dso_dlfcn.c:(.text+0x502): undefined reference to `dlerror'libs/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':dso_dlfcn.c:(.text+0x5a1): undefined reference to `dladdr'dso_dlfcn.c:(.text+0x601): undefined reference to `dlerror'libs/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':dso_dlfcn.c:(.text+0x662): undefined reference to `dlclose
async.c:(.text+0xe4): undefined reference to `pthread_setspecific'async.c:(.text+0xf4): undefined reference to `pthread_getspecific'async.c:(.text+0x104): undefined reference to `pthread_setspecific'/usr/local/openssl/lib/libcrypto.a(async.o): In function `ASYNC_init_thread.part.1':async.c:(.text+0x253): undefined reference to `pthread_setspecific'/usr/local/openssl/lib/libcrypto.a(async.o): In function `async_start_func':async.c:(.text+0x36f): undefined reference to `pthread_getspecific'async.c:(.text+0x39e): undefined reference to `pthread_getspecific'/usr/local/openssl/lib/libcrypto.a(async.o): In function `ASYNC_start_job':async.c:(.text+0x404): undefined reference to `pthread_getspecific'async.c:(.text+0x41e): undefined reference to `pthread_getspecific'async.c:(.text+0x433): undefined reference to `pthread_getspecific'/usr/local/openssl/lib/libcrypto.a(async.o):async.c:(.text+0x44c): more undefined references to `pthread_getspecific' follow/usr/local/openssl/lib/libcrypto.a(async.o): In function `ASYNC_start_job':async.c:(.text+0x7ef): undefined reference to `pthread_setspecific'async.c:(.text+0x811): undefined reference to `pthread_getspecific'async.c:(.text+0x82d): undefined reference to `pthread_getspecific'async.c:(.text+0x83f): undefined reference to `pthread_getspecific'async.c:(.text+0x870): undefined reference to `pthread_getspecific'async.c:(.text+0x891): undefined reference to `pthread_getspecific'/usr/local/openssl/lib/libcrypto.a(async.o):async.c:(.text+0x8a6): more undefined references to `pthread_getspecific' follow/usr/local/openssl/lib/libcrypto.a(async_posix.o): In function `async_global_init':async_posix.c:(.text+0xc): undefined reference to `pthread_key_create'async_posix.c:(.text+0x1e): undefined reference to `pthread_key_create'/usr/local/openssl/lib/libcrypto.a(async_posix.o): In function `async_local_init':async_posix.c:(.text+0x3d): undefined reference to `pthread_setspecific'async_posix.c:(.text+0x50): undefined reference to `pthread_setspecific'/usr/local/openssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
在CMakeList
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -Wall -std=c++11")
添加 -ldl -lpthread
plus:
curl master: https://github.com/curl/curl.gitcmake3 ../ -DBUILD_SHARED_LIBS=0 -DOPENSSL_ROOT_DIR=/data/code/openssl
posted on 2020-08-07 16:52 长戟十三千 阅读(122) 评论(0) 编辑 收藏 引用
libcurl linux 静态链接库_Linux ubuntu OpenSSL + curl 静态库编译及使用相关推荐
- linux 硬链接 软链接_Linux中的软链接–完整参考
linux 硬链接 软链接 A link in Linux systems are pointers to a file or a directory. There are two types of ...
- ubuntu导入第三方库_1.Ubuntu目录与第三方库
1.Ubuntu目录 一./:目录属于根目录,是所有目录的绝对路径的起始点,Ubuntu 中的所有文件和目录都在跟目录下. 二./etc:(and so on的意思,来源于法语)此目录非常重要,绝大多 ...
- 鸿蒙关键技术研究,鸿蒙内核源码分析(静态链接篇) | 完整小项目看透静态链接过程 | 百篇博客分析HarmonyOS源码 | v54.02...
百篇博客系列篇.本篇为: 下图是一个可执行文件编译,链接的过程. 本篇将通过一个完整的小工程来阐述ELF编译,链接过程,并分析.o和bin文件中各区,符号表之间的关系.从一个崭新的视角去看中间过程,阅 ...
- 静态库调用_静态链接和动态链接对比简析
0. 简介 在Linux环境下进行开发工作,代码要经过编译链接生成二进制可执行文件,才能被CPU识别并执行:程序的编译过程可以参考另外一篇文章<linux程序编译过程简析>:链接过程分为两 ...
- 利用ida对程序的静态链接库进行处理
用IDA进行反汇编时最怕遇到的就是跟踪到了程序静态链接的库函数中,看得一头雾水不说,还浪费了大量的时间.其实如果有符号表的话,看看函数名就知道大概功能了,再看看参数就可以pass了.本文以meterp ...
- 什么是链接?(动态链接库和静态链接库的对比)
什么是链接? 首先我们需要知道,一个源文件(以.c为例)是经过什么最后形成的一个可执行的文件(windows下为.exe文件). 一个.c的源文件,要经历 1.预处理:头文件的展开替换 2.编译:将对 ...
- 静态库、动态库、静态链接、动态链接、系统运行库混合、MD MT默认库冲突问题
一.静态库项目 静态库lib:(注意和"静态运行库"区分) 就是.lib文件,一个.c或.cpp会编译成一个.obj,多个.obj可以组合成一个.lib库.lib=多个obj. ...
- Codejock Xtreme ToolkitPro 静态链接XTP库以及皮肤库的使用
源码下载包含使用说明:http://download.csdn.net/download/weihuanzhen_yeah_net/5017822 1.配置_XTP_STATICLINK使能静态链接 ...
- 《视觉SLAM十四讲》第四讲-ubuntu下安装Sophus库出现问题及解决办法
这里写自定义目录标题 写在前面 1.安装指令: 2.编译过程中出现的问题及解决办法: 问题1: 问题2: 3.使用过程中出现的问题 参考链接 写在前面 本文转载自: [1] haxiongha. ub ...
最新文章
- Yann LeCun:未来几十年AI研究的最大挑战是「预测世界模型」
- MariaDB 10.0 和 MySQL 5.6 有何不同
- CRM One Order search max hit实现原理讨论
- Ant Design Vue页面数据复制
- 互联网日报 | 3月2日 星期二 | ​互联网人薪资报告:2021 开年薪资环比增长 7%...
- 黑鱼资源网完整版织梦整站源码打包分享
- matlab 赋空值,未对输出参数赋值 求大神帮忙解惑
- python用什么电脑配置好_学python用什么配置的电脑
- 课程管理系统(面向对象python)
- 利用层次分析法对熵权法进行修正
- 虚拟仿真实验平台服务器需求,虚拟仿真实验中心平台建设方案.pptx
- MFC API 设置Excel单元格格式
- mysql desc select_数据库里 desc 和 select 怎么用,代表什么意思?
- 同一目录下批处理执行Word宏
- 云虚拟主机bch 和 云服务器bcc,云虚拟主机bch 和 云服务器bcc
- 笔记本没有计算机和网络怎么回事,华为笔记本连wifi无internet怎么办?华为笔记本电脑怎么连不上网?...
- SSM框架搭建,及遇到的问题
- SQLAlchemy学习教程
- 解析访问www.baidu.com百度的流程?
- 价值180的仿3641美nv图库帝国CMS内核整站源码
热门文章
- CRT控制台显示中文乱码问题
- 梦幻西游游戏官网服务器状态,梦幻西游:凌晨4点了,这个游戏究竟还有几个服务器不是鬼区?...
- python零基础网站制作_为做网站而准备
- Java实现蓝桥杯单位转换
- Linux快速安装Python3.6 - 邱乘屹的个人技术博客
- idea重装后打不开,点起来没反应(难受)
- office修复找不到msi_windows7系统下打开office提示缺少pro11msi如何解决
- TFB cas:223569-31-1,聚合物光电材料
- java 山洞过火车 java,我的世界稀有PE种子:罕见双层末地门!
- 单片机中 读引脚 和读锁存器的区别