【昉·星光 2(VisionFive 2)RISC-V单板计算机】N种开发方式之-C开发:板上直接构建sqlite3

描述

前言

本板性能强劲,运行Debian桌面系统,所以我们完全可以直接板上开发,避免交叉编译开发带来的繁琐,本篇就以Sqlite3的编译测试为例来进行,体验直接板上进行C开发。

安装gcc工具链等可能需要比较大的空间,可参考如下文档。

https://www.elecfans.com/d/2185811.html

https://www.elecfans.com/d/2184550.html

联网,配置源可参考文档:

http://bbs.eeworld.com.cn/thread-1249527-1-1.html

http://bbs.eeworld.com.cn/thread-1249396-1-1.html

安装工具

sudo apt update

sudo apt upgrade

sudo apt-get install lrzsz //rz sz文件传输使用

sudo apt install make

sudo apt install gcc

sudo apt install git

sudo apt install tcl
sudo apt-get install tcl-dev

sudo apt install zlib1g-dev

下载源码

wget https://www.sqlite.org/src/tarball/sqlite.tar.gz

git clone https://github.com/sqlite/sqlite.git

构建

cd sqlite/

mkdir bld                ;#  Build will occur in a sibling directory

cd bld                   ;#  Change to the build directory

../configure      ;#  Run the configure script

make sqlite3.c           ;#  Build the "amalgamation" source file

make                     ;#  Run the makefile.

构建大概花了不到20min,也还是可以接受的,

运行 ./sqlite3

root@starfive:~/sqlite/bld# ./sqlite3

SQLite version 3.43.0 2023-07-18 13:55:19

Enter ".help" for usage hints.

Connected to a transient in-memory database.

Use ".open FILENAME" to reopen on a persistent database.

sqlite >

测试

make test ;# Run some tests (requires Tcl)

make test ;# Run some tests (requires Tcl)

如果报如下错误

/usr/bin/ld: /tmp/cccaPGbP.o: in function `fillInCell':

/root/sqlite/bld/./sqlite3.c:75921: undefined reference to `uncompress'

collect2: error: ld returned 1 exit status

make: *** [Makefile:714: sessionfuzz] Error 1

nano Makefile 添加-lz
交叉编译

报错tcl.h找不到,则查找

/usr/include/tcl8.6/tcl-private/generic/tcl.h

/usr/include/tcl8.6/tcl.h

添加头文件包含路径
交叉编译
如果提示tcl相关函数未定义

添加-ltcl
交叉编译

测试结果如下

交叉编译

交叉编译

总结

得益于开发板强劲的性能,直接在板上进行C开发非常方便,构建一般规模的项目时间还是可以接受的,省去了交叉编译的麻烦。

审核编辑:汤梓红

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
评论(0)
发评论
jf_44860206 2023-09-22
0 回复 举报
感谢大佬分享! 收起回复

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分