makefile and libpng

Nibbie
Posts: 4
Joined: 2009.09
Post: #1
hi,

I have a fink installed rev of libpng,

/sw/lib/
libpng.3.1.2.5.dylib
libpng.3.dylib
libpng12.0.1.2.5.dylib
libpng.12.0.dylib

Which libpng do I load in my makefile?

How do I load the lib in my link file?

LIBRARIES = -lGL -lGLU -lm -lobjc -lstdc++ <-- and what for libpng?

thanks,

Mike
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #2
I would assume -LGL, but I don't know much bout libraries. if you are using C++, use -lstdc++

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
libpng is already installed on my PowerBook... Presumably, it comes with Mac OS X. Just link to it with -lpng.

- Alex Diener
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.09
Post: #4
hi,

The make still fails with the -lpng ld option.

~/Game_Dev/png_lib] mnorton% make
g++ -framework GLUT -framework OpenGL -Wall -o pngExample -L"/System/Library/Frameworks/OpenGL.framework/Libraries" pngExample.o -lpng -lGL -lGLU -lm -lobjc -lstdc++
ld: can't locate file for: -lpng
make: *** [pngExample] Error 1

### Here is my makefile###
~/Game_Dev/png_lib] mnorton% more makefile
LIBDIR += -L"/System/Library/Frameworks/OpenGL.framework/Libraries"

FRAMEWORK = -framework GLUT
FRAMEWORK += -framework OpenGL

COMPILERFLAGS = -Wall
CC = g++
CFLAGS = $(COMPILERFLAGS)
LIBRARIES = -lpng -lGL -lGLU -lm -lobjc -lstdc++

OBJECTS = pngExample.o
All: pngExample

pngExample: pngExample.o $(OBJECTS)
$(CC) $(FRAMEWORK) $(CFLAGS) -o $@ $(LIBDIR) $(OBJECTS) $(LIBRARIES)
./pngExample

### here is more info on the location of my png file ###
~/Game_Dev/png_lib] mnorton% ls /usr/local/lib
ls: /usr/local/lib: No such file or directory
[Michael-Nortons-Computer:~/Game_Dev/png_lib] mnorton% ls /usr/lib/libpng*
ls: No match.
~/Game_Dev/png_lib] mnorton% ls /sw/lib/libpng*
/sw/lib/libpng.3.1.2.5.dylib /sw/lib/libpng12.0.1.2.5.dylib
/sw/lib/libpng.3.dylib /sw/lib/libpng12.0.dylib



Any ideas on how to make this work?

thanks,

Mike
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
your link flags should include

Code:
-L/sw/lib -lpng -lz
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.09
Post: #6
hi,

Thanks. That worked. Also, I had to install libpng from fink. Apparently, libpng wasn't installed in either /usr/lib or /sw/lib. The libs I pointed out above weren't libpng.
-or THE libpng - I should say.

ls libpng*
libpng.2.1.0.12.dylib libpng.a libpng12.a
libpng.2.dylib libpng.dylib libpng12.dylib
libpng.3.1.2.5.dylib libpng12.0.1.2.5.dylib
libpng.3.dylib libpng12.0.dylib

Once I installed libpng from fink commander -all was happy.

thanks a million!

Mike
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  libPng And Memory Access Violations Jaden 12 12,003 Sep 4, 2013 04:50 AM
Last Post: miye
  libpng loading junk at bottom of my OpenGL textures...? BinarySpike 6 6,077 Apr 19, 2007 12:20 PM
Last Post: BinarySpike
  libpng transparency problem wyrmmage 3 5,344 Mar 1, 2007 05:53 PM
Last Post: OneSadCookie
  Trouble writing PNGs with 16 bits per channel using libpng flash 2 3,791 Aug 28, 2006 11:01 AM
Last Post: flash
  libpng with OpenGL : return what? Jones 3 4,131 May 28, 2006 07:32 AM
Last Post: Jones