2

I was using SDL2 and its extension libs under Linux. Here are the steps I took to build SDL_image lib:

  1. Download libjpeg source, then standard 'configure;make;make install'
  2. Download SDL_image source, standard 'configure;make;make install'

I did the same for libpng So I'll omit the steps here.

When I tried to load a jpg file and a png file, respectively, I got the following error message: (ignore the prefix added by myself. The latter part came from SDL_GetError)

SDL_CTexture::load error: JPEG loading error
SDL_CRenderer:copy error: Invalid texture

for png:

SDL_CTexture::load error: Failed loading png_set_longjmp_fn: /lib/i386-linux-gnu/libpng12.so.0: undefined symbol: _png_set_longjmp_fn
SDL_CRenderer:copy error: Invalid texture

By the way, 'make check' gave a long list of fail when I tried to build libpng. But I did installed zlib for libpng beforehand.

Any ideas?


PS. From output of running './configure' when building SDL_image, it said 'yes' to both libpng and libjpeg.

PPS. OK now I found out that SDL_image was getting linked to /lib/i386-linux-gnu/libpng12.so, but my newly built libpng was installed in /usr/local/lib. How can I tell SDL_image to link to the newer version? I tried copying newer libs(libpng16.so) to /lib/i386-linux-gnu, but it was still referring to the old libpnf12.so.

PPPS. Finally I got it work by renaming my libpng16.so to libpng12.so.0 and copied this file to /lib/i386..., where SDL_image was referring to. However there is no decency in this solution. I'm still looking for a way to tell SDL_image that "hey use this newer libpng!"

1 Answer 1

1

It seems you do not compile with the correct lib release. Try to force your linker to take the right version in configure.

Have a look there http://www.willusher.io/sdl2%20tutorials/2013/08/18/lesson-3-sdl-extension-libraries/ in the qa section, a guy had the same issue as you.

This answer could also help CMake Finding Libraries on Wrong Path

3
  • I'll take a look. I just edited my post would you check that plz? Thanks a lot my friend!
    – Diaz
    Commented Feb 23, 2014 at 8:29
  • 1
    Your trick confirms the issue. Try to clean your cache and rebuild. Renaming the lib should not be the best fix. Good luck ;) Commented Feb 23, 2014 at 8:36
  • You are right. I tweaked configuration file for SDL2_image and now it worked like a charm. Thanks again!
    – Diaz
    Commented Feb 23, 2014 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.