栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

ubuntu sqlite3源码编译

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ubuntu sqlite3源码编译

1、首先从SQLite Download Page网站下载最新sqlite3源码,

2、选择sqlite3.c和sqlite3.h,sqlite3ext.h加载到工程中。

3、编写测试main.c函数:

#include 
#include 
#include "sqlite3.h"

int main()
{
    sqlite3 *db;
    int nResult = sqlite3_open("test.db", &db);
    if(nResult == SQLITE_OK)
    {
        printf("open successn");
    }
    else
    {
        printf("open failn");
    }

    return 0;
}

4、编写命令行命令:gcc -o main main.c sqlite3.c -lpthread -ldl -lm

如果不加上-lpthread -ldl -lm,则会报错,报错信息如下:

/usr/bin/ld: sqlite3.o: in function `pthreadMutexAlloc':
sqlite3.c:(.text+0x436e): undefined reference to `pthread_mutexattr_init'
/usr/bin/ld: sqlite3.c:(.text+0x437f): undefined reference to `pthread_mutexattr_settype'
/usr/bin/ld: sqlite3.c:(.text+0x439e): undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: sqlite3.o: in function `pthreadMutexTry':
sqlite3.c:(.text+0x4473): undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: sqlite3.o: in function `sqlite3ThreadCreate':
sqlite3.c:(.text+0x93ec): undefined reference to `pthread_create'
/usr/bin/ld: sqlite3.o: in function `sqlite3ThreadJoin':
sqlite3.c:(.text+0x9482): undefined reference to `pthread_join'
/usr/bin/ld: sqlite3.o: in function `unixDlOpen':
sqlite3.c:(.text+0x125a9): undefined reference to `dlopen'
/usr/bin/ld: sqlite3.o: in function `unixDlError':
sqlite3.c:(.text+0x125cc): undefined reference to `dlerror'
/usr/bin/ld: sqlite3.o: in function `unixDlSym':
sqlite3.c:(.text+0x1261f): undefined reference to `dlsym'
/usr/bin/ld: sqlite3.o: in function `unixDlClose':
sqlite3.c:(.text+0x12659): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [Makefile:12: main] Error 1

编译参考How To Compile SQLite

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/613163.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号