ld unable to find existing library

0 votes

I want to link my application with g++ on a debian system. But for sum reason ld cannot find the specified libraries. One such library is ImageMagick, but this is persistent with a few other libraries too.

I'm using linker:

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

ld error:

/usr/bin/ld: cannot find -lmagic

But, as you can see here, lib magic is present:

$ 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

Any idea how I should be moving along with this? Is there something completely wrong here?

Mar 19 in Linux Administration by Atul
• 5,530 points
44 views

1 answer to this question.

0 votes

your problem here is that your linker is looking for libmagic.so but you have the file called libmagic.so.1

Just try and create a symlink to to libmagic.so.1 to libmagic.so

It should solve your problem

answered Mar 19 by DareDev
• 6,810 points

Related Questions In Linux Administration

0 votes
1 answer

Cant find library in /usr/bin/ld

Say your library "libxyz.so" is located in: /home/user/myDir then ...READ MORE

answered Mar 26 in Linux Administration by ajs3033
• 7,240 points
28 views
0 votes
1 answer

How to find path of software installed in Linux?

There are multiple ways to find the ...READ MORE

answered May 19 in Linux Administration by Rishi
37 views
0 votes
1 answer

How to display a simple list of all disks, like this /dev/sda /dev/sdb ?

You can list all the disk in ...READ MORE

answered Jul 12, 2018 in Linux Administration by DearestOne
• 200 points
92 views
0 votes
2 answers

How do I find all files containing specific text on Linux?

grep -rnw 'text to find recursively inside ...READ MORE

answered May 20 in Linux Administration by Ritesh Singh
2,810 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
65 views
0 votes
1 answer

Install postgreSQL on Ubuntu

Installing PostgreSQL on Ubuntu is very simple, ...READ MORE

answered Mar 22 in Database by Nitesh
28 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22 in Database by Mahi
19 views
0 votes
1 answer

How to find the group associated with a user in linux?

To list all the groups groups or to list ...READ MORE

answered Jun 20 in Linux Administration by DareDev
• 6,810 points
11 views
0 votes
1 answer

set permanent path to Linux

Add it to your ~/.profile or ~/.bashrc file: export PATH="$PATH:/path/to/dir" You may ...READ MORE

answered Feb 27 in Linux Administration by DareDev
• 6,810 points
20 views