December 8, 2010

DotW DotW
Lab Rat
4 posts

[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

  1. // include QApplication and SDL_image here
  2. ...
  3. int main(int argc, char* argv[]) {
  4.    SDL_Init(SDL_INIT_VIDEO);
  5.    IMG_Init(IMG_INIT_PNG);
  6.    SDL_Surface* img = IMG_Load("test.png");
  7.    if (img) {
  8.         SDL_FreeSurface(img);
  9.         printf("Success\n");
  10.    }else
  11.         printf("Failed\n");
  12.    IMG_Quit();
  13.    SDL_Quit();
  14.    
  15.    QApplication app("My App", argc, argv);
  16.    // show main window here
  17.    ...
  18.    return app.exec();
  19. }

Output result

  1. libpng error: Decompression error
  2. Failed

But if I use SDL_image outside the Qt project, IMG_Load() works properly.

Source main.cpp without Qt

  1. // include SDL_image here
  2. ...
  3. int main(int argc, char* argv[]) {
  4.    SDL_Init(SDL_INIT_VIDEO);
  5.    IMG_Init(IMG_INIT_PNG);
  6.    SDL_Surface* img = IMG_Load("test.png");
  7.    if (img) {
  8.         SDL_FreeSurface(img);
  9.         printf("Success\n");
  10.    }else
  11.         printf("Failed\n");
  12.    IMG_Quit();
  13.    SDL_Quit();
  14.    
  15.    return 0;
  16. }

Output result

  1. Success
  2.  
  3. Software List:
  4. OS: Ubuntu 10.10
  5. Qt: Qt-4.6.2 opensource version
  6. SDL: libSDL-1.2.so.0.11.3
  7. 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

December 8, 2010

Volker Volker
Robot Herder
5428 posts

You can compile Qt manually with this switch:

  1. ./configure -system-libpng

That may solve your problem.

December 8, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

What platform is this?

December 8, 2010

Bradley Bradley
Lab Rat
314 posts

DotW wrote:

  1. Software List:
  2. OS: Ubuntu 10.10
  3. Qt: Qt-4.6.2 opensource version
  4. SDL: libSDL-1.2.so.0.11.3
  5. libpng: libpng 1.2.44

 Signature 

Nokia Certified Qt Specialist.

December 8, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

Doh, I missed that.

So I am guessing that you built Qt yourself (since Ubuntu Maverick ships with Qt 4.7.0)? If so, could you post the contents of mkspecs/qconfig.pri?

December 9, 2010

DotW DotW
Lab Rat
4 posts

By Volker,
You can compile Qt manually with this switch:
1
./configure -system-libpng
That may solve your problem.

Yeah, It really works!
Thanks a lot.

December 9, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

<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.

December 9, 2010

Volker Volker
Robot Herder
5428 posts

Gordon, the link is broken – it points to an non-existing page. Maybe a typo?

 
  ‹‹ Resulting executable file was too large (Windows Mobile)      Qml and Qt gui controls ››

You must log in to post a reply. Not a member yet? Register here!