Linux环境下MySQL++编译问题解决

MySQL++-2.1.1.tar.gz

安装步骤:
1、make clean
2、./configure
3、su
4、make
5、make install
6、ln -s /usr/local/lib/libmysqlpp.so /usr/lib/libmysqlpp.so

第6步很关键,建立符号连接,否则运行程序将出现如下错误:

./test: error while loading shared libraries: libmysqlpp.so: cannot open shared object file: No such file or directory

此处步骤占去了整个过程99%的时间。

Makefile:这个文件临时写的,可以简化,请高手不要见笑。

test:test.o
g++ test.o -o test -L/usr/lib/mysql -lmysqlclient -lmysqlpp
test.o:test.c
g++ -c test.c -I/usr/include/mysql -I/usr/local/include/mysql++
.PHONY:clean
clean:
-rm -f *.o test

测试代码:
test.c
#include
#include

using namespace std;

int main()
{
cout<<"hello"< getchar();
return 0;
}

如果还是不行,查看/etc/ld.so.conf文件,看是否包含了/usr/local/lib(mysql++的lib文件夹),如果没有,就加上,然后执行ldconfig

或者将/usr/local/lib 加入LD_LIBARAY_PATH , 可以echo $LD_LIBRARY_PATH看一看,source下。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzyxff.html