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, 2019 in Linux Administration by Atul
• 5,540 points
473 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, 2019 by DareDev
• 6,850 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, 2019 in Linux Administration by ajs3033
• 7,280 points
4,985 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, 2019 in Linux Administration by Rishi
1,401 views
0 votes
1 answer

fdisk: Unable to write /dev/sdg: Bad file descriptor

Hi@akhtar, You may get this error if your ...READ MORE

answered May 11 in Linux Administration by MD
• 56,480 points
126 views
0 votes
1 answer

Unable to login with GUI on CentOS/RHEL

Hi@akhtar, For new installation of CentOS/RHEL, GUI doesn't ...READ MORE

answered May 11 in Linux Administration by MD
• 56,480 points
90 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
184 views
0 votes
1 answer

Install postgreSQL on Ubuntu

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

answered Mar 22, 2019 in Database by Nitesh
155 views
0 votes
1 answer

Access progrs prompt without switching accounts

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

answered Mar 22, 2019 in Database by Mahi
104 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, 2019 in Linux Administration by DareDev
• 6,850 points
180 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, 2019 in Linux Administration by DareDev
• 6,850 points
73 views