交叉编译 libzdb

news2024/9/24 7:22:02

参考博客:移植libzdb3.2.2到arm_configure: error: no available database found or s_酣楼驻海的博客-CSDN博客

编译时间 2023-08-23

libzdb 下载:

源码访问如下:

https://bitbucket.org/tildeslash/libzdb/src/master/

git 下载链接

git clone https://bitbucket.org/tildeslash/libzdb.git

我将其同步到了 gitee,然后从 gitee 上下载的;

编译环境:

使用 ubuntu 18.04 版本;

在以下链接下载了 arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-linux-gnueabihf 交叉编译器;

https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads

编译:

1.源码下载后文件内容如下:

user:libzdb$ls
AUTHORS  bootstrap  CHANGES  config  configure.ac  COPYING  doc  libzdb.xcodeproj  Makefile.am  README  src  test  tools  zdb.pc.in

2.执行 bootstrap 生成 configure 文件

user:libzdb$./bootstrap 
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'config'.
libtoolize: linking file 'config/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: linking file 'm4/libtool.m4'
libtoolize: linking file 'm4/ltoptions.m4'
libtoolize: linking file 'm4/ltsugar.m4'
libtoolize: linking file 'm4/ltversion.m4'
libtoolize: linking file 'm4/lt~obsolete.m4'
configure.ac:46: installing 'config/compile'
configure.ac:103: installing 'config/config.guess'
configure.ac:103: installing 'config/config.sub'
configure.ac:8: installing 'config/install-sh'
configure.ac:8: installing 'config/missing'
Success
user:libzdb$ls
aclocal.m4  autom4te.cache  CHANGES  configure     COPYING  libzdb.xcodeproj  Makefile.am  README  test   zdb.pc.in
AUTHORS     bootstrap       config   configure.ac  doc      m4                Makefile.in  src     tools

3.使用 configure 来生成 Makefile

遇到问题1:configure: error: cross-compiling: please set 'libzdb_cv_setjmp_available=yes|no'

user:libzdb$./configure --host=arm-none-linux-gnueabihf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-linux-gnueabihf-strip... arm-none-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
......................
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking setjmp is available... configure: error: cross-compiling: please set 'libzdb_cv_setjmp_available=yes|no'

使用如下代码来判断是否支持 setjmp;交叉编译后在目标平台上执行,如果两个 printf 都打印就支持;

#include <stdio.h>
#include <setjmp.h>

jmp_buf jump_buffer;

void test_jump() {
    longjmp(jump_buffer, 1);
}

int main() {
    if (setjmp(jump_buffer) == 0) {
        printf("Calling test_jump()\n");
        test_jump();
    } else {
        printf("Back from test_jump()\n");
    }
    return 0;
}

4.使用新的命令编译,遇到问题2

libzdb_cv_setjmp_available=yes ./configure --host=arm-none-linux-gnueabihf

问题2:configure: error: cross-compiling: please set 'libzdb_cv_vsnprintf_c11_conformant=yes|no'

user:libzdb$libzdb_cv_setjmp_available=yes ./configure --host=arm-none-linux-gnueabihf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-linux-gnueabihf-strip... arm-none-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
................
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking setjmp is available... (cached) yes
checking vsnprintf is c11 conformant... configure: error: cross-compiling: please set 'libzdb_cv_vsnprintf_c11_conformant=yes|no'

使用如下代码来判断是否支持 vsnprintf;交叉编译后在目标平台上执行,如果正常打印就支持;

#include <stdio.h>
#include <stdarg.h>

void custom_printf(const char *format, ...) {
    char buffer[100];
    va_list args;
    
    va_start(args, format);
    vsnprintf(buffer, sizeof(buffer), format, args);
    va_end(args);

    printf("%s", buffer);
}

int main() {
    custom_printf("Hello %s, you have %d messages.\n", "Alice", 5);
    return 0;
}

5.使用新的命令编译,遇到问题3

libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf

问题3:configure: error: No available database found or selected. Try configure --help

user:libzdb$libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-linux-gnueabihf-strip... arm-none-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
...............................
checking for SQLite3... yes
checking for library containing sqlite3_open... no
checking for mysql... yes
checking for mysql_config... no
configure: WARNING: mysql_config is required to build libzdb with mysql
checking for oracle... checking if Oracle support is enabled... no
configure: error: No available database found or selected. Try configure --help

需要指定数据库,使用了 --with-sqlite

6.使用新的命令编译,遇到问题4

libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf --with-sqlite

问题4:configure: error: cannot check for file existence when cross compiling

user:libzdb$libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf --with-sqlite
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-linux-gnueabihf-strip... arm-none-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables
...............................
checking for timegm... yes
checking for library containing pthread_create... none required
checking for postgresql... yes
checking for pg_config... no
configure: WARNING: pg_config is required to build libzdb with postgresql
checking for SQLite3... yes
checking for yes... configure: error: cannot check for file existence when cross compiling

修改 configure 文件,将含有 "cannot check for file existence when cross compiling" 的行给注释掉,我一共注释了三行;

7.继续编译,遇到问题5

libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf --with-sqlite

问题5:configure: error: No available database found or selected. Try configure --help

user:libzdb$libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf --with-sqlite
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-none-linux-gnueabihf-strip... arm-none-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
...............................
configure: WARNING: pg_config is required to build libzdb with postgresql
checking for SQLite3... yes
checking for yes... no
checking for library containing sqlite3_open... no
checking for mysql... yes
checking for mysql_config... no
configure: WARNING: mysql_config is required to build libzdb with mysql
checking for oracle... checking if Oracle support is enabled... no
configure: error: No available database found or selected. Try configure --help

 需要指定 sqlite3 库的路径,文件放置如下:

user:sqlite3_bin$tree 
.
├── include
│   └── sqlite3.h
└── lib
    ├── libsqlite3.so -> libsqlite3.so.0.8.6
    ├── libsqlite3.so.0 -> libsqlite3.so.0.8.6
    └── libsqlite3.so.0.8.6

修改 --with-sqlite 为 --with-sqlite=/opt/liangtao/libs/sqlite3_bin/

8. 使用新命令编译,配置成功

libzdb_cv_setjmp_available=yes libzdb_cv_vsnprintf_c11_conformant=yes ./configure --host=arm-none-linux-gnueabihf --with-sqlite=/opt/liangtao/libs/sqlite3_bin/

9. 直接 make 遇到问题 6

问题6:./tools/bin/filterh < src/zdb.h > zdb/zdb.h || exit 1

user:libzdb$make 
./tools/bin/filterh < src/zdb.h > zdb/zdb.h || exit 1
/lib/ld-linux-armhf.so.3: No such file or directory
Makefile:1248: recipe for target 'zdb/zdb.h' failed
make: *** [zdb/zdb.h] Error 1
user:libzdb$

由于 filterh 是 arm 格式的,所以遇到该问题;

解决方法:重新下载一份源码,在源码顶层目录,直接运行以下命令,报错不用处理;

./bootstrap && ./configure

将 x86 的 ./tools/bin/filterh 替换交叉编译器相同的目录下的 filterh 文件;

user:libtmp$ls -al ./tools/bin/filterh 
-rwxrwxr-x 1 vmuser vmuser 23568 Aug 23 16:15 ./tools/bin/filterh
user:libtmp$file  ./tools/bin/filterh
./tools/bin/filterh: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=27cebe5d15f6c87b477fb1e0f69e283428cc4288, not stripped

10. 继续编译遇到问题 7

问题7:re2c: error: line 201, column 22: unrecognized configuration 'eof'

user:libzdb$make 
./tools/bin/filterh < src/zdb.h > zdb/zdb.h || exit 1
./tools/bin/filterh < src/zdbpp.h > zdb/zdbpp.h || exit 1
./tools/bin/filterh < src/db/ConnectionPool.h > zdb/ConnectionPool.h || exit 1
./tools/bin/filterh < src/db/Connection.h > zdb/Connection.h || exit 1
./tools/bin/filterh < src/db/ResultSet.h > zdb/ResultSet.h || exit 1
./tools/bin/filterh < src/net/URL.h > zdb/URL.h || exit 1
./tools/bin/filterh < src/db/PreparedStatement.h > zdb/PreparedStatement.h || exit 1
./tools/bin/filterh < src/exceptions/SQLException.h > zdb/SQLException.h || exit 1
./tools/bin/filterh < src/exceptions/Exception.h > zdb/Exception.h || exit 1
.................
ystem/System.c -o src/system/System.o >/dev/null 2>&1
/usr/bin/re2c -i src/system/Time.re > src/system/Time.c
re2c: error: line 201, column 22: unrecognized configuration 'eof'
Makefile:1261: recipe for target 'src/system/Time.c' failed
make[2]: *** [src/system/Time.c] Error 1
.................
Makefile:505: recipe for target 'all' failed
make: *** [all] Error 2

将文件 src/system/Time.re line 201 删除 

11.继续编译遇到问题 8

user:libzdb$make
make  all-recursive
make[1]: Entering directory '/opt/liangtao/libs/libzdb'
Making all in .
make[2]: Entering directory '/opt/liangtao/libs/libzdb'
/usr/bin/re2c -i src/system/Time.re > src/system/Time.c
re2c: error: line 211, column 17: unexpected character: '$'

接着将报错的行删除;

总的修改后 src/system/Time.re 文件如下:

diff --git a/src/system/Time.re b/src/system/Time.re
index 5b092e4..7b355ac 100644
--- a/src/system/Time.re
+++ b/src/system/Time.re
@@ -198,7 +198,6 @@ struct tm *Time_toDateTime(const char *s, struct tm *t) {
                  re2c:define:YYLIMIT         = limit;
                  re2c:define:YYMARKER        = marker;
                  re2c:yyfill:enable          = 0;
-                 re2c:eof                    = 0;
                  re2c:flags:case-insensitive = 1;
                  
                  any  = [\000-\377];
@@ -209,10 +208,6 @@ struct tm *Time_toDateTime(const char *s, struct tm *t) {
                  frac = [.,][0-9]+;
                  mmm  = ("jan"|"feb"|"mar"|"apr"|"may"|"jun"|"jul"|"aug"|"sep"|"oct"|"nov"|"dec");
 
-                 $
-                 { // EOF
-                        THROW(SQLException, "Invalid date or time");
-                 }
 
                  yyyy x dd x dd
                  { // Date: YYYY-MM-DD

12. 继续编译,后面遇到链接报错,没有在意,因为库文件已经编出;

user:libzdb$ls -a ./.libs/
.  ..  libzdb.a  libzdb.la  libzdb.lai  libzdb.so  libzdb.so.13  libzdb.so.13.1.0
user:libzdb$file ./.libs/libzdb.so.13.1.0
./.libs/libzdb.so.13.1.0: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, with debug_info, not stripped

注:删除的代码带来的影响不知;

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

JavaScript设计模式(一)——构造器模式、原型模式、类模式

个人简介 &#x1f440;个人主页&#xff1a; 前端杂货铺 &#x1f64b;‍♂️学习方向&#xff1a; 主攻前端方向&#xff0c;正逐渐往全干发展 &#x1f4c3;个人状态&#xff1a; 研发工程师&#xff0c;现效力于中国工业软件事业 &#x1f680;人生格言&#xff1a; 积跬步…

Lottery抽奖项目学习第二章第一节:环境、配置、规范

Lottery抽奖项目学习第二章第一节&#xff1a;环境、配置、规范 环境、配置、规范 下面以DDD架构和设计模式落地实战的方式&#xff0c;进行讲解和实现分布式抽奖系统的代码开发&#xff0c;那么这里会涉及到很多DDD的设计思路和设计模式应用&#xff0c;以及互联网大厂开发中…

【GoLang】go入门:go语言执行过程分析 常见数据类型(基本数据类型)

1、go语言执行过程分析 【1】执行流程分析 通过 go build 进行编译 运行上一步生成的可执行文件 通过 go run 命令直接运行 【2】上述两种执行流程的区别 在编译时&#xff0c;编译器会将程序运行时依赖的库文件包含在可执行文件中&#xff0c;所以可执行文件会变大很多通过g…

c++中的基本类型

专栏简介&#xff1a;为什么我要重新介绍c的相关知识&#xff0c;在此之前&#xff0c;我对于c的了解也仅仅是在表面。而在后来与c慢慢的接触中&#xff0c;c编程语言越来越让我觉得深奥&#xff0c;所以还是想要重新开创一个专栏来介绍c。对于c的介绍&#xff0c;本专栏会先介…

学会shell 基本语法,玩转linux

01、获取当前时间&#xff0c;年月日时分秒 now$(date %Y%m%d%H%M%S) echo "$now" 输出为&#xff1a;20181202222727 02、date 在脚本中的几种用法 date %Y 以 4 位数字格式打印年份 date %y 以 2 位数字格式打印年份 date %m 月份 date %d 日期 date %H 小时 d…

IO模型和NGINX安装升级

IO模型和NGINX安装升级 IO模型 IO概念 I/O在计算机中指Input/Output&#xff0c; IOPS (Input/Output Per Second)即每秒的输入输出量(或读写次数)&#xff0c;是衡量磁盘性能的主要指标之一。 Linux的IO类型 磁盘I/O 磁盘I/O是进程向内核发起系统调用&#xff0c;请求磁…

抖店出单后怎么操作?谈厂家话术与发货注意事项,抖店最新教程

我是王路飞。 当你的抖店出单后&#xff0c;你是怎么操作的? 还是像之前那样去拼多多代拍发货&#xff1f;这样做的商家&#xff0c;不知道你的店铺被封了几个了&#xff1f; 记住&#xff0c;现在抖店出单后&#xff0c;一定不要再去多多拍单发货了&#xff01; 关于抖店…

0基础入门C++之类和对象下篇

目录 1.再谈构造函数1.1构造函数赋值1.2初始化列表1.3explicit关键字 2.static成员2.1概念2.1静态成员变量2.2静态成员函数2.3特性 3.匿名对象4.友元函数4.1友元函数4.2友元类 5.内部类6.再次理解类和对象 1.再谈构造函数 首先我们先来回忆一下构造函数&#xff1a; 构造函数是…

【springboot】springboot定时任务:

文章目录 一、文档&#xff1a;二、案例&#xff1a; 一、文档&#xff1a; 【cron表达式在线生成器】https://cron.qqe2.com/ 二、案例&#xff1a; EnableScheduling //开启任务调度package com.sky.task;import com.sky.entity.Orders; import com.sky.mapper.OrderMapper; …

CAN总线学习——物理层、数据链路层、CANopen协议

1、CAN总线介绍 1.1、CAN总线描述 (1)CAN总线支持多节点通信&#xff0c;但是节点不分区主从&#xff0c;也就是不存在一个节点来负责维护总线的通信&#xff1b;这点可以和I2C总线对对比&#xff0c;I2C是一主多从模式&#xff1b; (2)是差分、异步、串行总线&#xff0c;采用…

分布式—雪花算法生成ID

一、简介 1、雪花算法的组成&#xff1a; 由64个Bit(比特)位组成的long类型的数字 0 | 0000000000 0000000000 0000000000 000000000 | 00000 | 00000 | 000000000000 1个bit&#xff1a;符号位&#xff0c;始终为0。 41个bit&#xff1a;时间戳&#xff0c;精确到毫秒级别&a…

Python slice(切片)

在Python中&#xff0c;切片(slice)是对序列型对象(如list, string, tuple)的一种高级索引方法。普通索引只取出序列中一个下标对应的元素&#xff0c;而切片取出序列中一个范围对应的元素&#xff0c;这里的范围不是狭义上的连续片段。 切片的基本语法为&#xff1a; object…

ChromeOS 的 Linux 操作系统和 Chrome 浏览器分离

导读科技媒体 Ars Technica 报道称&#xff0c;谷歌正在将 ChromeOS 的浏览器从操作系统中分离出来 —— 让它变得更像 Linux。虽然目前还没有任何官方消息&#xff0c;但这项变化可能会在本月的版本更新中推出。 据介绍&#xff0c;谷歌将该项目命名为 "Lacros"——…

防溺水预警识别系统算法

防溺水预警识别系统旨在通过opencvpython网络模型深度学习算法&#xff0c;防溺水预警识别系统算法实时监测河道环境&#xff0c;对学生等违规下水游泳等危险行为进行预警和提醒。Python是一种由Guido van Rossum开发的通用编程语言&#xff0c;它很快就变得非常流行&#xff0…

strcat函数

目录 函数介绍&#xff1a; 函数声明&#xff1a; 具体使用&#xff1a; 注意事项&#xff1a; 字符串⾃⼰给⾃⼰追加&#xff0c;如何&#xff1f; 模拟实现strcat函数&#xff1a; 函数介绍&#xff1a; 被称为字符串的追加/链接函数&#xff0c;它的功能就是在一个字符…

gcc/linux下的c++异常实现

概述 本文不一定具有很好的说教性&#xff0c;仅作为自我学习的笔记。不妨可参阅国外大神博文C exceptions under the hood链接中包含了大量的例子。 偶有在对ELF做分析的时候看到如下图一些注释&#xff0c;部分关键字看不懂&#xff0c;比如什么FDE, unwind , __gxx_perso…

【技巧分享】如何获取子窗体选择了多少记录数?一招搞定!

Hi,大家好久不见。 我这个更新速度是不是太慢了呀&#xff0c;因为&#xff0c;最近又又又在忙&#xff0c;请大家谅解啦。 现在更新文章、视频都要花好久去考虑&#xff0c;好不容易有个灵感了&#xff0c;一搜索&#xff0c;结果发现之前都已经分享过了&#xff08;委屈脸&…

Nginx详解 第三部分:Nginx高级配置(附配置实例)

Part 3 一、网页的状态页二、Nginx第三方模块2.1 echo 模块 三、变量3.1 内置变量3.1.1 常用内置变量3.1.2 举个例子 3.2 自定义变量 四、自定义访问日志 (优化)4.1 自定义访问日志的格式4.2 自定义json 格式日志 五、Nginx压缩功能&#xff08;重要&#xff09;六、HTTPS 功能…

SMC_Interpolator2Dir反向插补运动

附加函数是&#xff1a; SMC_Interpolator2Dir_SlowTask 函数的位置&#xff1a; 输入&#xff1a; 运行 bExecute 【BOOL】 路径包 poqDataIn 指向SMC_OUTQUEUE的指针 停止 bSlow_Stop 停止BOOL 急停 bEmergency_Stop 紧急停止BOOL 单…

2023.8 - java - 多态

多态是同一个行为具有多个不同表现形式或形态的能力。 多态就是同一个接口&#xff0c;使用不同的实例而执行不同操作&#xff0c; 多态的优点 1. 可替换性2 可扩充性3. 接口性、灵活性、简化性4. 消除类型之间的耦合关系 多态存在的三个必要条件 继承重写父类引用指向子类…