Link to home
Start Free TrialLog in
Avatar of mybluegrass
mybluegrass

asked on

ImageMagick and libpng link problem

When I compile ImageMagick, ./configure --prefix=/home/mmj works just fine. But when I execute "make", I got the following errors:

magick/.libs/libMagickCore.so: undefined reference to `png_longjmp'
magick/.libs/libMagickCore.so: undefined reference to `png_set_longjmp_fn'

The problem is that, when I compile, it's using the libpng1.5 but when I do make, it's linking to libpng1.4. libpng1.5 is installed locally under /home/mmj/lib and /home/mmj/include.

lib:
 libpng15.a
 libpng15.la
 libpng15.so -> libpng15.so.15.0.0
 libpng15.so.15 -> libpng15.so.15.0.0
 libpng15.so.15.0.0
 libpng.a -> libpng15.a
 libpng.la -> libpng15.la
 libpng.so -> libpng15.so

include:
libpng15/
pngconf.h  png.h  pnglibconf.h

How can I make sure that "make" will use the correct version libpng as well?

Thanks!
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

when I compile, it's using the libpng1.5 - are you sure? Do the compile lines contain -I/home/mmj/include? You should ensure that they do, if they don't already. However if you were using 1.4 headers, you should have got missing prototype warnings for png_longjmp and png_set_longjmp_fn (always assuming the warning level was set high enough).
You need to ensure the lines that load the shared  objects contain the gcc flag -L/home/mmj/lib. That is back to the configure stage, but first you should get a record of how make works now. make clean; make 2>&1 | tee hee will give you a record of your original make session in the file hee.
Now re-do configure as follows:
LDFLAGS=-L/home/mmj/lib ./configure --prefix=/home/mmj. This will force make to load with -L/home/mmj/lib but possibly not any other loader flags that ./configure used to generate. (I've only used this with CFLAGS, and certainly what I specified then entirely replaced the original flags). So try make again, and if it fails to make the shared objects then refer to hee and see what ld flags you are missing.
BTW you should probably do a make distclean before re-running ./configure (and every time you do)
Depening on your disitrubition there can be a "better" way to select this.

check pkg-config and for .pc files
ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@duncan_roe
Sorry I didn't mean to imply that pkg-config was dist specific.