本文介绍了如何在我的C ++应用程序中编译sqlite3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案:我刚刚添加 -lpthread -ldl 标志到我的makefile,它的工作原理!不知道为什么,但我很幸运,以避免编译sqlite3手工,因为我正在尝试..嗯,反正一些答案在哪里很好。谢谢你们,会为你喝一些茶。

SOLUTION: I just added -lpthread -ldl flags to my makefile and it works! Have no idea why, but I'm lucky enough to avoid compiling of sqlite3 by hand as I was trying.. Hmm, anyway some answers where pretty good. Thanks guys, will go and drink some tea for you.

三个月前我能找到如何做,但现在它不工作。我有一个巨大的C ++应用程序,在那里我需要嵌入sqlite3代码,但我不能编译它。我使用这样的:

Three months ago I was able to find how to do that but now it is not working. I have a huge C++ app, where I need to embed the sqlite3 code, but I can't compile it. I use something like this:

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

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

But it does not work; I have tried a lot of variations. I have a makefile, where I added sqlite3.h and sqlite3.c files. When I do make && make install in my app's particular folder, it shows errors:

.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'

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

This means that I need to add the -lpthread flag, when trying to compile sqlite3 separately from the app. Well, I am stuck.

推荐答案

您需要 -c 产生一个目标文件而不是链接。跳过库 - 您在连接整个应用程序时传递它们。

You need -c flag to produce an object file and not link. And skip the libraries — you pass them when linking the entire application.

gcc -c -o sqlite3.o sqlite3.c

这篇关于如何在我的C ++应用程序中编译sqlite3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:34