全国网站建设排名百度关键词挖掘查排名工具
记录一下linux安装 libpqxx遇到的一些问题
1.准备安装包:
1.准备安装包,以libpqxx-4.0.1.tar.gz为例子
链接如下:https://launchpad.net/libpqxx/+milestone/4.0.1
2.上传并安装
上传到安装目录并安装,我是放到/use/local下面
cd /usr/local/
tar xzvf libpqxx-4.0.1.tar.gz
cd libpqxx-4.0.1
./configure --prefix=/usr/local --enable-shared (这一步很重要,生成共享库 )
make clean
make
sudo make install
3.验证是否安装成功
(查看是否有 libpqxx.so文件)
cd /usr/local/lib/ |ls| grep libpqxx.so
4.测试代码
可以参考其他博主写的一些用例
Linux下C++连接postgresql_luffy5459的博客-CSDN博客
但是编译阶段可能报错: /usr/bin/ld: cannot find -lpq
ld: cannot find -lpq
collect2: error: ld returned 1 exit status
5.解决ld: cannot find -lpq:
需要更新 GCC 查找库的路径,我是用链接了安装 postgresql 库的目录中的文件,通常使用“usr/local/pgsql/lib”到“usr/include,也即:
ln -s /usr/local/postgresql/lib/* /usr/lib/
运行ldconfig,以更新/etc/ld.so.cache文件;
注意:(前提是之前已经在/etc/ld.so.conf.d/目录下新建任何以.conf为后缀的文件,在该文件中加入库文件所在的目录后,再运行ldconfig,以更新/etc/ld.so.cache文件;
)