I want to finally get to know how to write an application which uses database. I chose C++, PostgreSQL and SOCI (SQL wrapper to C++). I use Xubuntu 11.4 and installed everyting which was necessary to run a simple program.
To use SOCI I installed:
1) libboost-dev 2) libpq-dev 3) libtool 4) SOCI, using this: http://soci.sourceforge.net/doc/backends/postgresql.html#required and I compiled SOCI with this command: cmake cmake -G "Unix Makefiles" -DWITH_BOOST=ON -DWITH_POSTGRESQL=ON ../
My simple program is veeery simple:
#include "soci-postgresql.h"
int main(int argc, char **argv){
soci::session sql(postgresql, "testDB");
return 0;
}
I compile it like this:
g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq
but it gives me error:
test.cpp:1:29: fatal error: soci-postgresql.h: No such file or directory compilation terminated.
How to fix this, whats wrong? Did I miss to install something?
Some more infos:
/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
I also tried this one: g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I /usr/local/include/soci/postgresql
and got the error:
g++ test.cpp -lsoci_core -lsoci_postgresql -ldl -lpq -I /usr/local/include/soci/postgresql In file included from test.cpp:1:0: /usr/local/include/soci/postgresql/soci-postgresql.h:27:26: fatal error: soci-backend.h: No such file or directory compilation terminated.