解决方案:我刚刚添加-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
) last.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)