嵌入式开发-linux根文件系统(一)sqlite
sqlite
·
1. sqlite官网
官网:https://www.sqlite.org/
2. buildroot安装sqlite
/* 1. 添加sqlite软件包 */
ubuntu18@ubuntu18:~/imx6ull/buildroot$ make menuconfig
→ Target packages → Libraries → Database
[*] sqlite
[ ] Additional query optimizations (stat4)
[ ] Enable convenient access to meta-data about tables and queries
[ ] Enable version 3 of the full-text search engine
[ ] Enable the JSON extensions for SQLite
[ ] Enable sqlite3_unlock_notify() interface
[ ] Set the secure_delete pragma on by default
[ ] Disable fsync
ubuntu18@ubuntu18:~/imx6ull/buildroot$ make -j16
/* 2. sqlite库路径 */
/usr/lib/libsqlite3.so
/* 3. 烧写镜像或nfs挂载根文件系统测试 */
# sqlite3
SQLite version 3.37.2 2022-01-06 13:25:41
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .quit
3. yocto安装sqlite
/* 1. 添加sqlite软件包 */
/* 方法一: imx-image-multimedia的根文件系统已添加sqlite */
ubuntu18@ubuntu18:~/imx6ull/yocto/build-xwayland$ bitbake imx-image-multimedia
/* 方法二: core-image-minimal搭配自己的metadata */
IMAGE_INSTALL += "sqlite3"
/* 2. libsqlite3.so路径 */
/usr/lib/libsqlite3.so
4. ubuntu安装sqlite
ubuntu18@ubuntu18:~$ git clone https://github.com/sqlite/sqlite.git
ubuntu18@ubuntu18:~/sqlite$ ./configure
ubuntu18@ubuntu18:~/sqlite$ make
ubuntu18@ubuntu18:~/sqlite$ sudo make install
5. C/C++调用sqlite
/* 1. 通过CMake编译 */
/* CMakeList.txt */
cmake_minimum_required(VERSION 3.0.0)
project(my-sqlite VERSION 0.1.0)
include(CTest)
enable_testing()
# my-sqlite为生成的可执行文件名
add_executable(my-sqlite main.cpp)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
# 链接头文件
include_directories(/usr/local/include/sqlite3.h)
# 链接库文件
target_link_libraries(my-sqlite /usr/local/lib/libsqlite3.so)
/* main.cpp */
#include <iostream>
#include <sqlite3.h>
int main(int, char**)
{
return 0;
}
/* 2. 直接编译 */
:~$ gcc test.c -l sqlite3
:~$ g++ test.c -l sqlite3
:~$ ./a.out
更多推荐
已为社区贡献1条内容
所有评论(0)