postgres dbに接続する必要のある単純なcプログラムを作成しようとしましたが、次のコンパイルエラーに気付くことができません... Ubuntuを使用しています(ただし、すでにFedoraでコンパイルしようとしました-同じエラーで...)
uname --all
Linux alp2nwmon001 2.6.35-25-server #44-Ubuntu SMP Fri Jan 21 19:09:14 UTC 2011 x86_64 GNU/Linux
postgresを含むlibpq-devlibpq5libsをすでにインストールしましたが、この単純なコードが機能しない理由がわかりません...
#include "/usr/include/postgresql/libpq-fe.h"
int main () {
PGConn *test;
return 0;
}
また、次のような多くのバリエーションを試しました。また#include <libpq-fe.h>
、gccを呼び出すときに.hファイルへのパスを指定します。しかし、常に同じエラー...
gcc -c -I/usr/include/postgresql/ -L/usr/lib/ -lpq pqtest.c -o postgres
pqtest.c: In function main:
pqtest.c:4: error: PGConn undeclared (first use in this function)
pqtest.c:4: error: (Each undeclared identifier is reported only once
pqtest.c:4: error: for each function it appears in.)
pqtest.c:4: error: test undeclared (first use in this function)
さらに、私はたくさんのハウツーを見つけましたが、それでも同じ結果です:
- http://www.mkyong.com/database/how-to-building-postgresql-libpq-programs/
- http://forum.ubuntu-fr.org/viewtopic.php?pid=3212499
postgresのWebページでAPIの説明も確認しましたが、まだ運がありません。
私の意見では、すべてのファイルは存在すべき場所に存在します...
ls -lah /usr/include/postgresql/libpq-fe.h
-rw-r--r-- 1 root root 20K 2011-04-20 16:36 /usr/include/postgresql/libpq-fe.h
そして図書館...
ls /usr/lib/ | grep pq
libpq.a
libpq.so
libpq.so.5
libpq.so.5.2
libpqxx-2.6.9.so
libpqxx.la
libpqxx.so
誰かがここで私を助けてくれることを願っています...Thxbr、roegi