编译GRADS绘图软件时libgd相关链接失败,提示找不到../lib目录
Hi,我看了你遇到的GRADS编译问题,核心错误是libtool: line 6000: cd: ..//lib: No such file or directory,确实和路径配置以及libgd的链接有直接关系。结合你已经手动安装了libgd的情况,给你几个针对性的解决办法:
先确认并创建缺失的../lib目录
你当前编译的目录是/home/htan/grads-2.2.1/src,libtool要访问的上级目录下的lib文件夹(也就是/home/htan/grads-2.2.1/lib)不存在,导致报错。先手动创建这个目录:cd ~/grads-2.2.1 && mkdir -p lib创建完成后再重新运行
sudo make && sudo make install试试。重新运行configure,明确指定libgd的安装路径
虽然你已经装了libgd,但configure可能没正确识别到它的完整路径。可以重新执行configure命令,手动指定libgd的安装根目录(因为你的gdlib-config在/usr/local/bin,所以根目录是/usr/local):cd ~/grads-2.2.1 ./configure --with-gd=/usr/local完成后再重新编译。
修正Makefile里的路径错误
错误日志里显示路径是..//lib(多了一个斜杠),这可能是configure生成Makefile时的路径解析错误。你可以打开/home/htan/grads-2.2.1/src/Makefile,搜索..//lib,把所有出现的这个路径改成../lib,保存后再重新运行make。检查libgd的依赖是否完整
手动安装的libgd可能缺少必要的依赖库(比如libpng、zlib、libjpeg等),这些依赖会影响GRADS的链接过程。你可以运行以下命令查看libgd需要的依赖:gdlib-config --libs查看输出的参数(比如
-lpng -lz -ljpeg),如果某个库你没安装,就用系统包管理器安装对应的开发包(比如Debian/Ubuntu下的libpng-dev、zlib1g-dev,RHEL/CentOS下的libpng-devel、zlib-devel)。
你遇到的具体错误日志如下:
htan@HT:~/grads-2.2.1$ sudo make Making all in src make[1]: Entering directory '/home/htan/grads-2.2.1/src' make all-am make[2]: Entering directory '/home/htan/grads-2.2.1/src' /bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I..//include -g -O2 -rdynamic -c -o libgxpGD_la-gxprintGD.lo `test -f 'gxprintGD.c' || echo './'`gxprintGD.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I..//include -g -O2 -rdynamic -c gxprintGD.c -fPIC -DPIC -o .libs/libgxpGD_la-gxprintGD.o /bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I..//include -g -O2 -rdynamic -c -o libgxpGD_la-gxGD.lo `test -f 'gxGD.c' || echo './'`gxGD.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I. -I..//include -g -O2 -rdynamic -c gxGD.c -fPIC -DPIC -o .libs/libgxpGD_la-gxGD.o /bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -rdynamic -version-info 1:0:1 -o libgxpGD.la -rpath /home/htan/grads-2.2.1/lib libgxpGD_la-gxprintGD.lo libgxpGD_la-gxGD.lo -L..//lib -L/usr/local/lib -lgd -lm ../libtool: line 6000: cd: ..//lib: No such file or directory libtool: link: cannot determine absolute directory name of `..//lib' Makefile:711: recipe for target 'libgxpGD.la' failed make[2]: *** [libgxpGD.la] Error 1 make[2]: Leaving directory '/home/htan/grads-2.2.1/src' Makefile:610: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/htan/grads-2.2.1/src' Makefile:458: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1
备注:内容来源于stack exchange,提问作者Haochen

