I have compiled FreeImage from source and installed it.
When I run sudo make install
in installs the following files on my system
/usr/local/include/FreeImage.h
/usr/local/lib/libfreeimage-3.10.0.dylib
/usr/local/lib/libfreeimage.a
However in my C++ program it says error file not found
when I do this:
#include <FreeImage.h>
I have tried adding this to my system path file:
sudo vi /etc/paths
#FreeImage
/usr/local/include
/usr/local/lib
But C++ still cannot find my #include
inside Xcode or with gcc.
You don't want those directories in your
/etc/paths
file. That files lists the directories where the shell searches for executables.Try:
You might need to add
/usr/local/lib
to yourDYLD_LIBRARY_PATH
to make sure your executable runs:(Assuming your
DYLD_LIBRARY_PATH
variable doesn't have/usr/local/lib
, and that it's not empty to begin with. If it is empty, you should doexport DYLD_LIBRARY_PATH=/usr/local/lib
instead.)Edit: OK, based on your comments, looks like this should work:
See What to do if cmake doesn't find the package although it exists on the system? for more.
Since you're using a GUI version of Cmake, you should do this:
Open "property list editor", click "add child". For "New item", enter
CMAKE_INCLUDE_PATH
, for Type, leave it as "String", for Value, enter/usr/local/include
. Then, click "add item" again, and enterCMAKE_LIBRARY_PATH
for "New item", leave type as "String", and for "Value", enter/usr/local/lib
. Then save (File -> Save as) to a file. I suggest filenamea.plist
in your Desktop folder. Then open a terminal (Appilcations -> Utilities -> Terminal) and type:After that, quit Xcode and Cmake gui, and restart. That should work. See this for technical details, and this for more.