Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved] Qt conflict with SDL on libpng?
Forum Update on Monday, May 27th 2025

[solved] Qt conflict with SDL on libpng?

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 4 Posters 6.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DotW
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You can compile Qt manually with this switch:

      @
      ./configure -system-libpng
      @

      That may solve your problem.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GordonSchumacher
        wrote on last edited by
        #3

        What platform is this?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

          [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
          @

          Nokia Certified Qt Specialist.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GordonSchumacher
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DotW
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                GordonSchumacher
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

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

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved