I have compiled FreeImage 3.10.0 from source at /lib/FreeImage on Mac OS X 10.6.
I can see that after compilation these files were copied:
/usr/local/lib/libfreeimage-3.10.0.dylib
/usr/local/lib/libfreeimage.a
/usr/local/include/FreeImage.h
CMake cannot find FreeImage, but I cannot even do
#include <FreeImage.h> // not found
I am assuming I need to add FreeImage.h to the Mac OS X environment path, except I don't know which path is the right one as there are a few different files which store environment path variables.
What do I need to do to get FreeImage header to be found by my C++ app or CMake?
Here is the first part of my Makefile.osx
is this helps:
# -*- Makefile -*-
# Mac OSX makefile for FreeImage
# This file can be generated by ./gensrclist.sh
include Makefile.srcs
# General configuration variables:
CC_PPC = gcc-4.0
CC_I386 = gcc-4.0
CPP_PPC = g++-4.0
CPP_I386 = g++-4.0
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden
COMPILERFLAGS_PPC = -arch ppc
COMPILERFLAGS_I386 = -arch i386
COMPILERPPFLAGS = -Wno-ctor-dtor-privacy
INCLUDE +=
INCLUDE_PPC = -isysroot /Developer/SDKs/MacOSX10.6.sdk
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.6.sdk
CFLAGS_PPC = $(COMPILERFLAGS) $(COMPILERFLAGS_PPC) $(INCLUDE) $(INCLUDE_PPC)
CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $(INCLUDE_I386)
CPPFLAGS_PPC = $(COMPILERPPFLAGS) $(CFLAGS_PPC)
CPPFLAGS_I386 = $(COMPILERPPFLAGS) $(CFLAGS_I386)
LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk
LIBTOOL = libtool
LIPO = lipo
Update: I added these lines into my Makefile as per Nicholas' instructions, then rebuilt but this didn't work:
CFLAGS = -I/usr/local/include
LDFLAGS = -L/usr/local/lib
Compiling with gcc -c file.c -o file.o -I /usr/local/include should compile your file that refers FreeImage.h.
However, when using isysroot everything becomes relative to the system root (i.e. your refrence to /usr/local/include is in fact isysroot/usr/local/include). "gcc -v" will show everything that goes on, making things easy:
The '
INCLUDE +=
' line looks like the one to attack:If the library is missing too, then you will need to find another line to add '
-L/usr/include/lib
' to.You have to add -I/usr/local/include to CFLAGS and -L/usr/local/lib to LDFLAGS when compiling.