【发布时间】:2015-04-18 10:52:32
【问题描述】:
我有一个名为 matrix 的库,并在我的程序中使用,名为 test.cpp。
我可以成功生成和使用 static 库,但是当我想将它用作 shared 库时,我收到以下错误:
ap1019@sharifvm:~/the03-copy$ ls
matrix.cpp matrix.h test.cpp
ap1019@sharifvm:~/the03-copy$ g++ -c matrix.cpp
ap1019@sharifvm:~/the03-copy$ g++ -shared -Wl,-soname,matrix.so -o matrix.so matrix.o
ap1019@sharifvm:~/the03-copy$ ls
matrix.cpp matrix.h matrix.o matrix.so test.cpp
ap1019@sharifvm:~/the03-copy$ g++ test.cpp matrix.so
ap1019@sharifvm:~/the03-copy$ ./a.out
./a.out: error while loading shared libraries: matrix.so: cannot open shared object file: No such file or directory
ap1019@sharifvm:~/the03-copy$
有人知道吗?
【问题讨论】:
标签: c++ g++ shared-libraries