Hi All,

I am new to C++ on linux enviroment and am trying to use the png++ library for a project. The problem i am facing is that that a simple program i write using png++ incudes does not work and shows me the following errors

AProg.o: In function png::info_base::info_base(png::io_base&, png_struct_def*):
AProg.cpp (.text._ZN3png9info_baseC2ERNS_7io_baseEP14png_struct_def[_ZN3png9info_baseC5ERNS_7io_baseEP14png_struct_def]+0x21): undefined reference to png_create_info_struct
AProg.o: In function png::info::write() const:
AProg.cpp:(.text._ZNK3png4info5writeEv[png::info::write() const]+0xd4): undefined reference to png_set_PLTE
AProg.cpp:(.text._ZNK3png4info5writeEv[png::info::write() const]+0x137): undefined reference to png_set_tRNS
AProg.cpp:(.text._ZNK3png4info5writeEv[png::info::write() const]+0x14f): undefined reference to png_write_info
AProg.o: In function png::info::sync_ihdr() const:
AProg.cpp:(.text._ZNK3png4info9sync_ihdrEv[png::info::sync_ihdr() const]+0x79): undefined reference to png_set_IHDR
AProg.o: In function png::end_info::destroy():
AProg.cpp:(.text._ZN3png8end_info7destroyEv[png::end_info::destroy()]+0x48): undefined reference to png_destroy_info_struct
AProg.o: In function png::end_info::write() const:
AProg.cpp:(.text._ZNK3png8end_info5writeEv[png::end_info::write() const]+0x1a): undefined reference to png_write_end
AProg.o: In function png::io_base::set_swap() const:
AProg.cpp:(.text._ZNK3png7io_base8set_swapEv[png::io_base::set_swap() const]+0x1b): undefined reference to png_set_swap
.............. (and it goes on).

The background of what i have done so far.

1 : I have gcc/g++ configured correctly.

2 : I have followed the following instructions ( http://www.techsww.com/tutorials/libraries/libpng/installation/installing_libpng_on_ubuntu_linux.php ) and correctly install libpng-1.2.50. The result seems to be correct.

This is how my usr/local folder looks now

:/usr/local/include$ ls
libpng12 libpng15 png++ pngconf.h png.h pnglibconf.h



:/usr/local/include$ ls
libpng12 libpng15 png++ pngconf.h png.h pnglibconf.h



:/usr/local/lib$ ls
libpng12.a libpng12.so libpng12.so.0.50.0 libpng15.la libpng15.so.15 libpng.a libpng.so libpng.so.3.50.0 python2.7
libpng12.la libpng12.so.0 libpng15.a libpng15.so libpng15.so.15.12.0 libpng.la libpng.so.3 pkgconfig



:/usr/local/bin$ ls
eclipse libpng-1.2.50 libpng12-config libpng-1.5.12 libpng15-config libpng-config png++-0.2.5

3 : After that i followed the following ( http://www.nongnu.org/pngpp/doc/0.2.5/ ) to install the png++-0.2.5 and all the five steps didnt gave any error.

But after that when i tried to compile a simple program (with the instructions given at the same site : http://www.nongnu.org/pngpp/doc/0.2.5/ ) it would not compile.

:~/workspace/AProg$ g++ -o AProg AProg.o 'libpng-config --ldflags'
g++: error: libpng-config --ldflags: No such file or directory

Then i tried to solve the problem and google it and gave this command which seems to work fine at compile but when i tried to run it. I got the error as mentioned at the top of the post

:~/workspace/AProg$ g++ -c AProg.cpp -I/usr/local/include/libpng12 -L/usr/local/lib -lpng -I/usr/local/include/png++

:~/workspace/AProg$

I am sorry for such a long post. But i just wanted to explain anything /everything related to my problem. Hope somebody helps me here.

Quotes in linker line, is not correct. It should be back quotes. The one in tilde button under escape button.

Comments
Thanks, it worked
This article has been dead for over six months. Start a new discussion instead.