-1

libpng error undefined symbol png_read_image in unix
i'm developing a program with C language in unix sco open server 5.0.7
and now, i need to use libpng in my project to load a png file
when i include in my code (png.h and code are in same directory) and compile program there was no error.
but when i use png.h methods such as png_read_image or png_sig_cmp and compile it, compiler send me error:
undefined symbol png_read_image
amd other can anybody help me?

Farrokh
  • 1,167
  • 1
  • 7
  • 18
  • did you link you program with libpng? if not, you have to pass -Lpng to compiler to do that – folibis Jul 23 '14 at 03:56
  • I linked lsocket when compling,how can i do multiple linking?
    and seems libong not installed correctly, how can i install it?
    – Farrokh Jul 23 '14 at 04:00
  • 1
    in same way as you link lsocket. For example: gcc -o myprogram myprogram.o -L/path/to/libpng.o -I/path/to/libpng/headers -lpng -lsocket . – folibis Jul 23 '14 at 04:06
  • Ah, sorry, I misleaded you. to link to some library you have to use -l flag. -L flag is to set path to this library – folibis Jul 23 '14 at 04:07
  • is this true? " cc evoip.c -Llibpng.a -lpng -lsocket – Farrokh Jul 23 '14 at 04:12
  • should be gcc evoip.c -L -lpng -lsocket i.e. gcc evoip.c -L/usr/local/lib -lpng -lsocket – Ankit Patel Jul 23 '14 at 04:17
  • Sorry but I don't know what is `cc`. Anyway you should pass the option to linker, not to compiler – folibis Jul 23 '14 at 04:18

1 Answers1

0

You need to include add library for compiling.

Example: gcc -static myfile.c -L/user/local/lib -lmath -o execfile

See the gcc syntax at http://www.rapidtables.com/code/linux/gcc.htm

Ankit Patel
  • 1,191
  • 1
  • 9
  • 9