[solved] Qt conflict with SDL on libpng?
Since both Qt and SDL are cross-platform. I’m trying to use QT to browse files, and SDL to play the video file.
Qt load png resource correctly, but SDL_image always fail with “Decompression error” on IMG_Load().
Source main.cpp within Qt project
- // include QApplication and SDL_image here
- ...
- int main(int argc, char* argv[]) {
- SDL_Init(SDL_INIT_VIDEO);
- IMG_Init(IMG_INIT_PNG);
- SDL_Surface* img = IMG_Load("test.png");
- if (img) {
- SDL_FreeSurface(img);
- printf("Success\n");
- }else
- printf("Failed\n");
- IMG_Quit();
- SDL_Quit();
- // show main window here
- ...
- return app.exec();
- }
Output result
- libpng error: Decompression error
- Failed
But if I use SDL_image outside the Qt project, IMG_Load() works properly.
Source main.cpp without Qt
- // include SDL_image here
- ...
- int main(int argc, char* argv[]) {
- SDL_Init(SDL_INIT_VIDEO);
- IMG_Init(IMG_INIT_PNG);
- SDL_Surface* img = IMG_Load("test.png");
- if (img) {
- SDL_FreeSurface(img);
- printf("Success\n");
- }else
- printf("Failed\n");
- IMG_Quit();
- SDL_Quit();
- return 0;
- }
Output result
- Success
- Software List:
- OS: Ubuntu 10.10
- SDL: libSDL-1.2.so.0.11.3
- libpng: libpng 1.2.44
It seems that Qt has built-in libpng, and load libpng at start-up, so SDL cannot load the correct version of libpng within Qt project.
Any suggestions on how to avoid this?
Thanks,
DocW
(edit: adjusted layout / mariusg)
7 replies
<plug type=“shameless”>You might take a look at this wiki page [developer.qt.nokia.com] – it is IMNSHO a good overview of the options to “configure”.</plug>
EDIT: fixed the link.
You must log in to post a reply. Not a member yet? Register here!



