ld cannot find an existing library

 am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.

I am calling the linker with:

g++ -w (..lots of .o files/include directories/etc..) \ 
-L/usr/lib -lmagic 

ld complains:

/usr/bin/ld: cannot find -lmagic 

However, libmagic exists:

$ locate libmagic.so 
/usr/lib/libmagic.so.1 
/usr/lib/libmagic.so.1.0.0 
$ ls -all /usr/lib/libmagic.so.1* 
lrwxrwxrwx 1 root root    17 2008-12-01 03:52 /usr/lib/libmagic.so.1 -> libmagic.so.1.0.0 
-rwxrwxrwx 1 root root 84664 2008-09-09 00:05 /usr/lib/libmagic.so.1.0.0 
$ ldd /usr/lib/libmagic.so.1.0.0  
    linux-gate.so.1 =>  (0xb7f85000) 
    libz.so.1 => /usr/lib/libz.so.1 (0xb7f51000) 
    libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7df6000) 
    /lib/ld-linux.so.2 (0xb7f86000) 
$ sudo ldconfig -v | grep "libmagic" 
    libmagic.so.1 -> libmagic.so.1.0.0 

How do I diagnose this problem further, and what could be wrong? Am I doing something completely stupid?

 

The problem is the linker is looking for libmagic.so but you only have libmagic.so.1

A quick hack is to symlink libmagic.so.1 to libmagic.so

 

 

that works, I am kind of perplexed that it would name the file in a completely useless way by default - can you provide any insight why it would do this by default? –  maxpenguin Dec 3 '08 at 1:09
 
Most likely it is a misconfiguration of the install script –  grepsedawk Dec 3 '08 at 1:15
 
The foo.so.1 is a symlink to foo.so.1.0.0 too. This way, you can have several versions of a library in your system, and if an application needs a specific one, it can link to it, while in general, the newest one is chosen by symlink. I do not know why this symlink was missing. –  Svante Dec 3 '08 at 1:19
 
libmagic.so.1 is the soname, used by the dynamic linker; libmagic.so is used by the linker, and is usually together with the headers in the -dev package. The symlink might be missing because the -dev package was not installed. –  CesarB Dec 3 '08 at 10:49

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值