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
As just formulated by grepsedawk, the answer lies in the -l
option of g++
, calling ld
. If you look at the man page of this command, you can either do:
g++ -l:libmagic.so.1 [...]
g++ -lmagic [...]
, if you have a symlink named libmagic.so in your libs pathIt is Debian convention to separate shared libraries into their runtime components (libmagic1: /usr/lib/libmagic.so.1 → libmagic.so.1.0.0
) and their development components (libmagic-dev: /usr/lib/libmagic.so → …
).
Because the library's soname is libmagic.so.1
, that's the string that gets embedded into the executable so that's the file that is loaded when the executable is run.
However, because the library is specified as -lmagic
to the linker, it looks for libmagic.so
, which is why it is needed for development.
See Diego E. Pettenò: Linkers and names for details on how this all works on Linux.
In short, you should apt-get install libmagic-dev
. This will not only give you libmagic.so
but also other files necessary for compiling like /usr/include/magic.h
.
In Ubuntu, you can install libtool
which resolves the libraries automatically.
$ sudo apt-get install libtool
This resolved a problem with ltdl
for me, which had been installed as libltdl.so.7
and wasn't found as simply -lltdl
in the make.
As mentioned above the linker is looking for libmagic.so
, but you only have libmagic.so.1
.
To solve this problem just perform an update cache.
ldconfig -v
To verify you can run:
$ ldconfig -p | grep libmagic
Unless I'm badly mistaken libmagic
or -lmagic
is not the same library as ImageMagick. You state that you want ImageMagick.
ImageMagick comes with a utility to supply all appropriate options to the compiler.
Ex:
g++ program.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs` -o "prog"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With