データベースを使用するアプリケーションの書き方を最終的に知りたいです。C++、PostgreSQL、および SOCI (C++ への SQL ラッパー) を選択しました。Xubuntu 11.4 を使用し、簡単なプログラムを実行するために必要なすべてをインストールしました。
私がインストールしたSOCIを使用するには:
1) libboost-dev 2) libpq-dev 3) libtool 4) SOCI: http://soci.sourceforge.net/doc/backends/postgresql.html#requiredを使用し、次のコマンドで SOCI をコンパイルしました: cmake cmake - G "Unix Makefile" -DWITH_BOOST=ON -DWITH_POSTGRESQL=ON ../
私の単純なプログラムは非常に単純です。
#include "soci-postgresql.h"
int main(int argc, char **argv){
soci::session sql(postgresql, "testDB");
return 0;
}
私は次のようにコンパイルします:
g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq
しかし、それは私にエラーを与えます:
test.cpp:1:29: 致命的なエラー: soci-postgresql.h: そのようなファイルまたはディレクトリのコンパイルは終了しませんでした。
これを修正する方法、何が問題なのですか? 何かをインストールするのを逃しましたか?
いくつかの詳細情報:
/usr/local/include/soci$ ls
backend-loader.h postgresql soci-platform.h
blob-exchange.h prepare-temp-type.h soci-simple.h
blob.h procedure.h statement.h
boost-fusion.h ref-counted-prepare-info.h transaction.h
boost-gregorian-date.h ref-counted-statement.h type-conversion.h
boost-optional.h row-exchange.h type-conversion-traits.h
boost-tuple.h row.h type-holder.h
connection-pool.h rowid-exchange.h type-ptr.h
empty rowid.h unsigned-types.h
error.h rowset.h use.h
exchange-traits.h session.h use-type.h
into.h soci-backend.h values-exchange.h
into-type.h soci-config.h values.h
once-temp-type.h soci.h version.h
/usr/local/include/soci/postgresql$ ls
common.h soci-postgresql.h
/usr/local/lib$ ls
libCOS4.a libomniORB4.so.1
libCOS4.so libomniORB4.so.1.6
libCOS4.so.1 libomnithread.a
libCOS4.so.1.6 libomnithread.so
libCOSDynamic4.a libomnithread.so.3
libCOSDynamic4.so libomnithread.so.3.4
libCOSDynamic4.so.1 libsoci_core.a
libCOSDynamic4.so.1.6 libsoci_core.so
libomniCodeSets4.a libsoci_core.so.3.1
libomniCodeSets4.so libsoci_core.so.3.1.0
libomniCodeSets4.so.1 libsoci_empty.a
libomniCodeSets4.so.1.6 libsoci_empty.so
libomniConnectionMgmt4.a libsoci_empty.so.3.1
libomniConnectionMgmt4.so libsoci_empty.so.3.1.0
libomniConnectionMgmt4.so.1 libsoci_postgresql.a
libomniConnectionMgmt4.so.1.6 libsoci_postgresql.so
libomniDynamic4.a libsoci_postgresql.so.3.1
libomniDynamic4.so libsoci_postgresql.so.3.1.0
libomniDynamic4.so.1 pkgconfig
libomniDynamic4.so.1.6 python2.7
libomniORB4.a python3.2
libomniORB4.so
私もこれを試しましg++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I /usr/local/include/soci/postgresql
た:そしてエラーが発生しました:
g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I /usr/local/include/soci/postgresql test.cpp:1:0 からインクルードされたファイル: /usr/local/include/soci/postgresql/soci-postgresql .h:27:26: 致命的なエラー: soci-backend.h: そのようなファイルまたはディレクトリのコンパイルは終了しませんでした。