编译C和sqlite3

我在编写一个程序时遇到了一些麻烦。 过去几天我一直在search互联网,试图find一个解决scheme。 我正在使用MinGW编译器,并已经尝试过:

如果它帮助这是我testing这个代码,我不能得到的包括显示为代码,但他们都在插入依次,iostream,stdio.h,和sqlite3.h它返回错误“致命错误:sqlite3.h:没有这样的文件或目录“。 我将所有的包含文件放在与.cpp源文件相同的目录中。

int main(int argc, char* argv[]) { sqlite3 *db; char *zErrMsg = 0; int rc; rc = sqlite3_open("text.db", &db); return 0; } 

 #include <stdio.h> #include "sqlite3.h" int main(int argc, char* argv[]) { sqlite3 *db; char *zErrMsg = 0; int rc; rc = sqlite3_open("text.db", &db); return 0; } 

编译和测试结果:

 w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ mingw32-gcc -o test main.c sqlite3.c -I./ w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ ll total 8485 -rw-r--r-- 1 w00343520 1049089 192 六月 8 10:38 main.c -rw-r--r-- 1 w00343520 1049089 236938 五月 26 00:15 shell.c -rw-r--r-- 1 w00343520 1049089 7130198 五月 26 00:15 sqlite3.c -rw-r--r-- 1 w00343520 1049089 498184 五月 26 00:15 sqlite3.h -rw-r--r-- 1 w00343520 1049089 30199 五月 26 00:15 sqlite3ext.h -rwxr-xr-x 1 w00343520 1049089 785640 六月 8 10:38 test.exe* w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ ./test.exe w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ ll total 8485 -rw-r--r-- 1 w00343520 1049089 192 六月 8 10:38 main.c -rw-r--r-- 1 w00343520 1049089 236938 五月 26 00:15 shell.c -rw-r--r-- 1 w00343520 1049089 7130198 五月 26 00:15 sqlite3.c -rw-r--r-- 1 w00343520 1049089 498184 五月 26 00:15 sqlite3.h -rw-r--r-- 1 w00343520 1049089 30199 五月 26 00:15 sqlite3ext.h -rwxr-xr-x 1 w00343520 1049089 785640 六月 8 10:38 test.exe* -rw-r--r-- 1 w00343520 1049089 0 六月 8 10:41 text.db w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ 

shell.c的测试结果:

 w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ mingw32-gcc -o sqlite shell.c sqlite3.c -I./ w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ ./sqlite.exe w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ ./sqlite.exe --help Usage: D:\Download\sqlite-amalgamation-3190200\sqlite-amalgamation-3190200\sqlite.exe [OPTIONS] FILENAME [SQL] FILENAME is the name of an SQLite database. A new database is created if the file does not previously exist. OPTIONS include: -ascii set output mode to 'ascii' -bail stop after hitting an error -batch force batch I/O -column set output mode to 'column' -cmd COMMAND run "COMMAND" before reading stdin -csv set output mode to 'csv' -echo print commands before execution -init FILENAME read/process named file -[no]header turn headers on or off -help show this message -html set output mode to HTML -interactive force interactive I/O -line set output mode to 'line' -list set output mode to 'list' -lookaside SIZE N use N entries of SZ bytes for lookaside memory -mmap N default mmap size set to N -newline SEP set output row separator. Default: '\n' -nullvalue TEXT set text string for NULL values. Default '' -pagecache SIZE N use N slots of SZ bytes each for page cache memory -scratch SIZE N use N slots of SZ bytes each for scratch memory -separator SEP set output column separator. Default: '|' -stats print memory stats before each finalize -version show SQLite version -vfs NAME use NAME as the default VFS w00343520@wuhy1w001184171 MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 $ 

在摆弄了一下之后,我意识到我只需要在源文件目录中包含“sqlite3.h”和sqlite.h文件,并将sqlite3.c文件包含在项目树中。 我正在使用DevC ++,我去了项目>添加到项目,并选择sqlite3.c文件。 然后项目>项目选项>文件,然后选择sqlite3.c,然后取消选中“编译为C ++文件”。