2017-06-08 6 views
1

私が書いているプログラムにsqlite3を組み込む際に問題があります。私は解決策を見つけることを試みている過去数日間インターネットを精練してきました。私はMinGWのコンパイラを使用していますし、すでに試してみました:\ MinGWの\ binディレクトリにはスペースのないユーザーおよびシステム環境パス変数の両方に含まれており、セミコロンCとsqlite3のコンパイル

で分離されている:

  • は、Cの確保します

  • 結果を返すすべての関連ファイルの同じディレクトリに "C:¥MinGW¥bin¥gcc shell.c sqlite3.c -lpthread -ldl"と入力すると、 "c:/ mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe:-ldlを見つけることができません collect2.exe:エラー:ldが1の終了ステータスを返しました "

  • フレッシュMinGWのをインストールし、それが、これは私がこれをテストしていたコードであることができます場合は、私がコードとして表示することが含まれるが、それらは順番にキャレットですべてです、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; 
} 

答えて

0

私は私がしたしなければならなかったすべてを実現少し周りいじる後#include "sqlite3.h"をソースファイルディレクトリのsqlite.hファイルとともに使用し、プロジェクトツリーにsqlite3.cファイルをインクルードします。 DevC++を使用していて、プロジェクトに追加してプロジェクトに追加し、sqlite3.cファイルを選択しました。次にプロジェクト>プロジェクトオプション>ファイルを選択し、sqlite3.cを選択して、 "C++としてファイルをコンパイルする"のチェックを外します。

1
#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; 
} 

コンパイルおよびテスト結果:shell.cため

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ mingw32-gcc -o test main.c sqlite3.c -I./ 

[email protected] 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* 

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ ./test.exe 

[email protected] 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 

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ 

テスト結果:

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ mingw32-gcc -o sqlite shell.c sqlite3.c -I./ 

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ ./sqlite.exe 



[email protected] 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 

[email protected] MINGW64 /d/Download/sqlite-amalgamation-3190200/sqlite-amalgamation-3190200 
$ 
+0

私はあなたが何をしたのか、それを動作させるために何が必要なのかは完全にはわかりません。 –

+0

彼がしたことは、 '$'プロンプトの後ろに表示されているすべてを入力することでした。 –

+0

システム上でsqliteをコンパイルしてテストしました。ログを添付してください。私はこれがあなたの問題を解決するのに役立つことを願っています。 – Jimmy