静态库链接不上,是怎么回事呢?
时间:2011-01-07
来源:互联网
在Linux下 编译一个NCL 的C程序需要链接libnetcdf.a的一个静态库,它放在/usr/local/lib下,
编译时使用命令nhlcc -o test test.c -l/usr/local/lib/libnetcdf.a (NCL 自带命令)
即gcc -DSYSV -D_POSIX_SOURCE -D_XOPEN_SOURCE -DByteSwapped -D__UNIXOS2__ -DNeedFuncProto -ansi -fPIC -O0 -o cn14c cn14c.c -l/usr/local/lib/libnetcdf.a -L/usr/local/lib -I/usr/local/include -lhlu -lncarg -lncarg_gks -lncarg_c -lX11 -lXext -lgfortran -lm
但是报错
/usr/bin/ld: cannot find -l/usr/local/lib/libnetcdf.a
我查看了/ect/ld.so.conf.d/lic.conf文件中默认路径为/usr/local/lib 没有错啊,请问为什么还链不进去呢?
求高手指点!
编译时使用命令nhlcc -o test test.c -l/usr/local/lib/libnetcdf.a (NCL 自带命令)
即gcc -DSYSV -D_POSIX_SOURCE -D_XOPEN_SOURCE -DByteSwapped -D__UNIXOS2__ -DNeedFuncProto -ansi -fPIC -O0 -o cn14c cn14c.c -l/usr/local/lib/libnetcdf.a -L/usr/local/lib -I/usr/local/include -lhlu -lncarg -lncarg_gks -lncarg_c -lX11 -lXext -lgfortran -lm
但是报错
/usr/bin/ld: cannot find -l/usr/local/lib/libnetcdf.a
我查看了/ect/ld.so.conf.d/lic.conf文件中默认路径为/usr/local/lib 没有错啊,请问为什么还链不进去呢?
求高手指点!
作者: yan2865 发布时间: 2011-01-07
gcc -L
作者: lostyue 发布时间: 2011-01-07
gcc -L 库的路径
作者: lostyue 发布时间: 2011-01-07
-L/usr/local/lib -lnetcdf
试一下
试一下
作者: yifanernei 发布时间: 2011-01-07
-L/usr/local/lib 也不行,报错
/tmp/ccU3mxIK.o: In function `main':
cn14c.c:(.text+0x892): undefined reference to `ncopen'
cn14c.c:(.text+0x8b2): undefined reference to `ncdimid'
cn14c.c:(.text+0x8d2): undefined reference to `ncdimid'
cn14c.c:(.text+0x906): undefined reference to `ncdiminq'
cn14c.c:(.text+0x933): undefined reference to `ncdiminq'
cn14c.c:(.text+0x94c): undefined reference to `ncvarid'
cn14c.c:(.text+0x9a7): undefined reference to `ncvarget'
cn14c.c:(.text+0x9c0): undefined reference to `ncvarid'
cn14c.c:(.text+0xa10): undefined reference to `ncvarget'
cn14c.c:(.text+0xa29): undefined reference to `ncvarid'
cn14c.c:(.text+0xa49): undefined reference to `ncvarid'
cn14c.c:(.text+0xac0): undefined reference to `ncvarget'
cn14c.c:(.text+0xafb): undefined reference to `ncvarget'
cn14c.c:(.text+0xb0a): undefined reference to `ncclose'
collect2: ld returned 1 exit status
库还是没有链进去的。
/tmp/ccU3mxIK.o: In function `main':
cn14c.c:(.text+0x892): undefined reference to `ncopen'
cn14c.c:(.text+0x8b2): undefined reference to `ncdimid'
cn14c.c:(.text+0x8d2): undefined reference to `ncdimid'
cn14c.c:(.text+0x906): undefined reference to `ncdiminq'
cn14c.c:(.text+0x933): undefined reference to `ncdiminq'
cn14c.c:(.text+0x94c): undefined reference to `ncvarid'
cn14c.c:(.text+0x9a7): undefined reference to `ncvarget'
cn14c.c:(.text+0x9c0): undefined reference to `ncvarid'
cn14c.c:(.text+0xa10): undefined reference to `ncvarget'
cn14c.c:(.text+0xa29): undefined reference to `ncvarid'
cn14c.c:(.text+0xa49): undefined reference to `ncvarid'
cn14c.c:(.text+0xac0): undefined reference to `ncvarget'
cn14c.c:(.text+0xafb): undefined reference to `ncvarget'
cn14c.c:(.text+0xb0a): undefined reference to `ncclose'
collect2: ld returned 1 exit status
库还是没有链进去的。
作者: yan2865 发布时间: 2011-01-07
把-L/usr/local/lib -lnetcdf放在链接库的最后面
还有使用nm看一下netcdf里面有ncopen之类的符号么,防止库有问题
还有使用nm看一下netcdf里面有ncopen之类的符号么,防止库有问题
作者: xunxun1982 发布时间: 2011-01-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28