我尝试在main.c文件中使用sqlite库:
#include <stdio.h>
#include "sqlite3.h"
int main() {
printf("%s\n", sqlite3_libversion());
return 0;
}
字符串
但我得到了以下错误:
CMakeFiles\Database.dir/objects.a(main.c.obj): In function `main':
C:/Users/Andrea/Desktop/Database/main.c:7: undefined reference to `sqlite3_libversion'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\Database.dir\build.make:104: Database.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:94: CMakeFiles/Database.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:101: CMakeFiles/Database.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:136: Database] Error 2
型
我从官方网站下载了sqlite3.h文件,并将其放在main.c文件的同一个文件夹中。下面是CMakeList.txt:
cmake_minimum_required(VERSION 3.19)
project(Database C)
set(CMAKE_C_STANDARD 11)
add_executable(Database main.c sqlite3.h)
型
请问,你能帮我修改CMakeList.txt文件,使代码可以编译?
1条答案
按热度按时间gz5pxeao1#
你要做的就是从这个网站下载almagation的源代码:almagation.它有你需要的所有c文件。解压后,你可以这样使用它:
字符串
希望这对你有帮助!