Undefined symbols for architecture i386: "_png_set_longjmp_fn"

Hi folks, i’m trying to link png.h correctly ( for some code i am wrangling over to openFrameworks). I’ve spent a day trying different combinations of flags and includes etc. But i keep getting this linker error

  
  
ld: warning: ignoring file /opt/local/lib/libpng.dylib, file was built for unsupported file format which is not the architecture being linked (i386)  
Undefined symbols for architecture i386:  
  "_png_set_longjmp_fn", referenced from:  

However this same code does compile on the command line using a makefile. This being the relevant bits from the makefile being

  
# assumes MacPorts libpng installation  
PNG_INCLUDE =  -I/opt/local/include/libpng14  
PNG_LIBS =  -L/opt/local/lib    
  
LDFLAGS    =  $(PNG_LIBS)-lz -lpng $(OPENMPLD_FLAGS) -t  
  
CFLAGS     =  -c -Wall -I./ $(PNG_INCLUDE) $(OPENMP_FLAGS) -O3 -Wno-unused  
EXECUTABLE = FLUID_3D  

To explain more…i have a project that i am researching regarding turbulence. I have downloaded the project and macports libpng and it builds and runs using the associated makefile. Now i want to run the project from within an openFrameworks example project in XCode 4, i have it working 99% however i have to comment out anything relating to png.h (which is just a debug dump of the turbulence per frame to a png file). However i am having some other non related issues and now want to check the png file it outputs.

In the command line version (that works 100%) the make -t shows

  
/opt/local/lib/libz.dylib  
/opt/local/lib/libpng.dylib  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib  
/usr/lib/libSystem.dylib  
/usr/lib/system/libmathCommon.A.dylib  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(parallel.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(env.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(proc.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(team.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(error.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(bar.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(alloc.o)  
/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64/libgomp.a(sem.o)  
  

I guess the only important value here is /opt/local/lib/libpng.dylib. So i assume the commandline version finds “_png_set_longjmp_fn” in that lib whereas the XCode ld is maybe linking to a different libpng* that has some odd architecture? Just guessing.

Any help (on a friday evening) appreciated.

nik

yes, you need to configure macports to use i386 instead of 64bits.

that said freeimage also includes libpng so trying to link twice with the same library can be problematic. theoretically they do something so the symbols are hidden but we’ve had problems with cairo which also includes libpng and opencv when compiled with png support. it links but then freeimage is not able to read pngs anymore

thanks arturo that worked great. (well it built, whether it actually outputs the png file correctly will have to wait till later).