0

I need to use libpng for my coursework with Qt. But I don't know how to install it and use with Qt on Windows.

Try to install with MinGw

Firstly, I've downloaded libpng and zlib from official site. Then I've tried to install it with MinGw, ./configure CFLAGS='-O2' CXXFLAGS='-O2' --prefix=/mingw this command executes perfectly, but then I got a problem. After typing make and make install I've got following issue. I don't know how to fix it and what it actually mean, because I've never faced errors from makefiles.

Try to install via application

I've found an application for installing libpng on windows: http://gnuwin32.sourceforge.net/packages/libpng.htm. And it worked, I've installed a library, got my lib files and headers. Then I went to my Qt project, and added a library, by pointing path to lib file and path to headers. Now I'm including png.h in my class and things seems to go well, until I try to use some functions. Qt writes something like this No mathcing function for call to png_sig_cmp. But more interestingly, that it actually don't show errors when I use variable types from library, for example png_byte.

//messege from MinGw after typing make and make install
rm -f pnglibconf.c pnglibconf.tf[45]
gawk -f ./scripts/options.awk out=pnglibconf.tf4 version=search\
            ./pngconf.h ./scripts/pnglibconf.dfa\
            ./pngusr.dfa  1>&2
gawk -f ./scripts/options.awk out=pnglibconf.tf5 pnglibconf.tf4 1>&2
options.awk: bad line (10): com
make: *** [pnglibconf.c] Error 1

I expect to install library on my disk and be able to include it in other projects in other IDE fast.

  • Why was not there png support from the beginning? I use Qt for many years and never tried to install that manually. https://doc.qt.io/qt-5/qtimageformats-index.html – Alexander V Apr 06 '19 at 13:57
  • @AlexanderV this is my course work and this is a stupid restriction on using libpng and not using Qt clases for image work. – Gleb Bessudnov Apr 06 '19 at 14:11
  • I am unsure why Qt then complains about the function missing while it can only be your own code that misses it. Otherwise you should explore https://doc.qt.io/qtcreator/creator-project-qmake-libraries.html https://doc.qt.io/qt-5/third-party-libraries.html https://stackoverflow.com/questions/718447/adding-external-library-into-qt-creator-project Maybe the last one is enough. – Alexander V Apr 06 '19 at 15:20

1 Answers1

0
  1. For your build problem Google search yields: https://github.com/aseprite/aseprite/issues/1054#issuecomment-335846694 .

  2. Suppose you built not libpng, but libcurl as I did a while ago with mingw compiler, then to use libcurl within your Qt project file do:

win32 {

    ## Windows common build here

     win32-g++:contains(QMAKE_HOST.arch, x86_64):{
        message("x86_64 build")
        INCLUDEPATH += C:\QT64\Lib64\curl-7.40.0-devel-mingw64\include
        LIBS += C:\Qt64\Lib64\curl-7.40.0-devel-mingw64\lib64\libcurldll.a
        # Win64 specific build here

     } else {
             message("x86 build")
             INCLUDEPATH += C:\QT\Lib\curl-7.40.0-devel-mingw32\include
             LIBS += C:\Qt\Lib\curl-7.40.0-devel-mingw32\lib\libcurldll.a
             #Win32 specific build here
            }
}
sirop
  • 181
  • 1
  • 13
  • I've successfuly installed library, but now I have another issue. When I trie to make my project I got a following warning: _warning lnk4098 defaultlib libcmtd conflicts with use of other libs; use /nodefaultlib:library_. I've searhced on Internet for the solution, but none of them helped me out. – Gleb Bessudnov Apr 07 '19 at 09:51
  • Check this: https://www.qtcentre.org/threads/69006-Qt-Creator-error-NODEFAULTLIB-library-No-such-file-or-directory?s=fed13459e59a4f9556d23da256074c04&p=301515#post301515 – sirop Apr 07 '19 at 11:07