Congratulations to our 2022 Qt Champions! brings 51 undefined reference errors when linking Qt.

  • Hi, I'm on Sabayon Linux ( a fork of Gentoo), and while I've just started using Qt, I've been able to compile and run my programs in Qt Creator for a while now without any issues. It's only when I pass Config += qt that I get issues. I've tried passing in core or gui, just as is, but that still won't allow the actual project to compile.

    Here are my errors:

    @/home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_read_info@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_set_gAMA@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_get_tRNS@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_set_PLTE@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_filler@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_get_text@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_packing@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_write_rows@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_invert_mono@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_set_error_fn@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_write_chunk@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_get_image_width@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_IHDR@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_set_sig_bytes@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_read_update_info@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_set_interlace_handling@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_write_fn@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_write_end@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_create_read_struct@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_read_image@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to png_set_gray_to_rgb@PNG12_0' /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference topng_get_IHDR@PNG12_0'
    /home/holland/QtSDK/Desktop/Qt/4.8.0/gcc/lib/ undefined reference to `png_get_channels@PNG12_0'@

    I'm not quite sure what to do about this. I've tried reinstalling the sdk, and while that has gone fairly smoothly, I still haven't been able to get this working on my development machine. Everything is up to date, as well.

    QMake File

    @TEMPLATE = app
    win32:CONFIG += console
    CONFIG += qt core gui

    QMAKE_CXX_FLAGS += -std=c++0x

    SOURCES +=

    HEADERS +=

    win32:LIBS += -glew32 -lglu32 -lopengl32 -lkernel32 -lgdi32 -luser32 -lws2_32

    unix:LIBS += -lX11 -lGLEW -lGLU -lGL -lXext -L/usr/X11R6/lib@

    Thank you to anyone who can provide assistance. :)

  • Perhaps libpng isn't available in the library path.

  • Should I just do export PATH = /path/to/libpng/?

  • If it's not seeing it at compile time,
    LIBS += -L/path/to/libpng/location

  • Hmm...I've tried both export PATH and your LIBS method; unfortunately, they don't work. Do you have any other ideas?


    It looks like I'm able to pass CONFIG = opengl | core | gui, just no += operator.

    I can't get CONFIG = qt, however.

  • Looks like you're missing

    unix:LIBS += -lpng

    It's strange that it's not added by qmake, though, as it is a dependency of QtGui lib, and not directly of your code.

    One cause could be that you have libpng installed, but the version doesn't match with that required by the SDK.

  • Damn, that one didn't work either. :(

    I think you're right, though: my libpng version is 1.5.6 AND 1.4.8, so I'm guessing Qt must not be referencing these properly. Is there somewhere I can go and edit a few things to tinker around with this?


    I got it to work!

    For Sabayon users, just do:

    equo search libpng
    equo install libpng-1.2.46

    It seems like Qt's version is a few versions behind, but regardless, this will definitely allow you do build your projects with Qt now!


Log in to reply