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 ffdfd
• 5,550 points
3,839 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,890 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,300 points
12,410 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 20, 2019 in Linux Administration by Rishi
8,359 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, 2020 in Linux Administration by MD
• 95,460 points
2,080 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, 2020 in Linux Administration by MD
• 95,460 points
2,816 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
1,185 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
1,278 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
850 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 21, 2019 in Linux Administration by DareDev
• 6,890 points
945 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,890 points
843 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP