gpt4 book ai didi

c++ - 如何在我的 C++ 应用程序中编译 sqlite3?

转载 作者:太空狗 更新时间:2023-10-29 20:46:13 26 4
gpt4 key购买 nike

解决方案:我刚刚将 -lpthread -ldl 标志添加到我的 makefile 中,它就可以工作了!不知道为什么,但我很幸运能够在尝试时避免手动编译 sqlite3。嗯,无论如何,一些答案非常好。谢谢大家,我去给你们喝点茶。

三个月前我能够找到如何做到这一点,但现在它不起作用。我有一个巨大的 C++ 应用程序,我需要在其中嵌入 sqlite3 代码,但我无法编译它。我使用这样的东西:

gcc sqlite3.c -lpthread -ldl -o ./sqlite3.o

但是它不起作用;我尝试了很多变化。我有一个 makefile,我在其中添加了 sqlite3.h 和 sqlite3.c 文件。当我在我的应用程序的特定文件夹中执行 make && make install 时,它显示错误:

.libs/sqlite3.o: In function `pthreadMutexTry':
/home/.../client/sqlite3.c:17769: undefined reference to `pthread_mutex_trylock'
.libs/sqlite3.o: In function `pthreadMutexAlloc':
/home/.../client/sqlite3.c:17637: undefined reference to `pthread_mutexattr_init'
/home/.../client/sqlite3.c:17638: undefined reference to `pthread_mutexattr_settype'
/home/.../client/sqlite3.c:17640: undefined reference to `pthread_mutexattr_destroy'

这意味着我需要添加 -lpthread 标志,当我试图从应用程序中单独编译 sqlite3 时。好吧,我卡住了。

最佳答案

链接时库在命令行上的顺序很重要。将库 (-lpthread -ldl) 放在最后。

关于c++ - 如何在我的 C++ 应用程序中编译 sqlite3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8702302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com