Reputation: 987
I was using SDL2 and its extension libs under Linux. Here are the steps I took to build SDL_image lib:
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!"
Upvotes: 2
Views: 2745
Reputation: 1491
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
Upvotes: 1