我是这个领域的新手。 我正在安装一个在运行时链接到另一个库 (gsl) 的库,如下所示:
g++ x.cpp y.cpp z.cpp -o abc -lgsl -lm -lgslcblas
我目前正在服务器上工作,因此没有 root 权限。
gsl 是一个依赖项,因此我在本地安装了 gsl。以下是我遵循的步骤:
1) Downloaded the gsl-latest.tar.gz
2) tar -zxvf gsl-latest.tar.gz
3) From inside the gsl-1.16 (latest) folder I did:
a) ./configure --prefix=local-folder-path
b) make
c) make check
d) make install
Everything is successfully completed.
现在,由于主库将其链接为运行时,因此我在 LD_LIBRARY_PATH 中设置了此 bin 的路径。
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/a/b/c/gsl-1.16-bin/bin/
现在,当我转到主库的文件夹并执行“make”时,它仍然会出现以下错误,例如:
error: gsl/gsl_vector.h: No such file or directory
error: ‘gsl_vector_get’ was not declared in this scope
error: ‘gsl_vector_set’ was not declared in this scope
error: ‘gsl_vector_get’ was not declared in this scope
error: ‘gsl_vector_set’ was not declared in this scope
error: ‘gsl_vector_memcpy’ was not declared in this scope
At global scope:
error: ISO C++ forbids declaration of ‘gsl_vector’ with no type
error: expected ‘,’ or ‘...’ before ‘*’ token
我还需要在其他地方设置路径吗?
如有任何帮助,我们将不胜感激。 谢谢您
最佳答案
问题是 include
路径。您需要在编译行添加 -I
来查找目录。
也可以指定 RPATH Wikipedia RPATH指定在哪里查找库
关于c++ - Linux 中的库链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32445000/