Karolinny Moura
Karolinny Moura

Reputation: 41

Can't find library png++

I'm trying to use the png++ library. Already added it to the library search path in eclipse (windows user, if relevant), but I get the

fatal error: png++/png.hpp: No such file or directory

I really don't know what to do. Thank you!

Upvotes: 3

Views: 4709

Answers (2)

Karolinny Moura
Karolinny Moura

Reputation: 41

After days, tears and blood, my professor (PhD Daniel Brake) figured it out! Here is what we did to make it work. I hope you never need to use this library on a Windows machine (conf: Windows 10, MinGW, Eclipse):

  • Make sure that you have the MinGW installation manager, have all the packages on the basic setup installed, and in "all packages", look for "msys-zlib", class dll
  • Now open the cmd (Windows+x, A, to open in admin mode)
  • You have to open the "msys.bat", go to C:\MinGW\msys\1.0\msys.bat
  • It will open a unix-like terminal, then type:
    • mingw-get install libz-dev
    • cd /path/to/libpng/folder
    • ./configure -prefix=/mingw
    • make
    • make install
  • Google png++, download it, and using the MinGW terminal go to the folder that contains it:
    • cd /path/to/png++/folder
    • tar -zxf png++-0.2.x.tar.gz -C
  • In the png++ page, go to http://savannah.nongnu.org/bugs/?46312 and donwnload the file to the png++ folder
  • Replace the error.hpp file
  • Using a text editor, open the error.hpp file you just downloaded
  • Add #include <sstream> to the includes
  • look for the part and comment it:

    strerror_r(errnum, buf, ERRBUF_SIZE); return std::string(buf);

  • Now, add this in the same block of above: std::stringstream ss; ss << errnum; return ss.str();
  • Save and close
  • Now, open Eclipse, create the project for the png++
  • Go to Configuration > C/C++ Build > set Configuration to "Debug [Active]"
  • Then C/C++ Build > Settings > GCC C++ compiler, add to "Include paths (-l)", the path to the folder png++ and the path to the folder that contains the file png.h, in my case it's in "C:\MinGW\msys\1.0\mingw\include"
  • Go to MinGW C++ Linker > Libraries, add to "Libraries (-l)" just the word "png" and in the "Library seach path (-L)" the path to the folder of libpng.a, in my case, "C:\MinGW\msys\1.0\mingw\lib"
  • save
  • to use it, in the header, add #include <png.hpp> (not #include <png++/png.hpp>)
  • it will have a warning, you can ignore it
  • it doesn't works!
  • in your MinGW terminal, go to the folder that have the "eclipse.exe" and open the Eclipse that way (don't ask me, my professor said something about path, I have no idea why) Maybe you can simply use another compiler, but I couldn't, or use Linux.

Upvotes: 1

Sreekar
Sreekar

Reputation: 1015

Okay. You need to check your settings one by one.

  • It (png++) is a C++ library, so you must have C++ compiler set in your run/debug settings.
  • Add your library include folder to that compiler's settings
  • To actually link to the library, you need to add the .lib/.a files or DLLs to linker settings.

I'm not much of a user of Eclipse CDT but that's how it works. If you are trying to do image manipulation without prior C++ experience, I suggest you to go with python/Java, they are easy to use.

Upvotes: 1

Related Questions