[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();

    QApplication app("My App", argc, argv);
    // 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
    Qt: Qt-4.6.2 opensource version
    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)



  • You can compile Qt manually with this switch:

    @
    ./configure -system-libpng
    @

    That may solve your problem.



  • What platform is this?



  • [quote author="DotW" date="1291822509"]
    @
    Software List:
    OS: Ubuntu 10.10
    Qt: Qt-4.6.2 opensource version
    SDL: libSDL-1.2.so.0.11.3
    libpng: libpng 1.2.44
    @



  • 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?



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



  • <plug type="shameless">You might take a look at "this wiki page":http://developer.qt.nokia.com/wiki/BuildQtForLinux - it is IMNSHO a good overview of the options to "configure".</plug>

    EDIT: fixed the link.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.