#include< FreeImage.h>未找到 [英] #include <FreeImage.h> not found

查看:189
本文介绍了#include< FreeImage.h>未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从源代码编译FreeImage并安装它。



当我运行 sudo make install 系统上的以下文件

  /usr/local/include/FreeImage.h 
/ usr / local / lib / libfreeimage-3.10.0.dylib
/usr/local/lib/libfreeimage.a

但是在我的C ++程序中,当我这样做时,表示未找到错误文件

  #include< FreeImage.h> 

我已尝试将其添加到我的系统路径文件中:

  sudo vi / etc / paths 

#FreeImage
/ usr / local / include
/ usr / local / lib

但是C ++仍然找不到我的 #include

解决方案

您不需要 $ c> / etc / paths 文件。该文件列出了shell搜索可执行文件的目录。



尝试:

  $ CFLAGS = -  I / usr / local / includeLDFLAGS = -  L / usr / local / libmake 
$ sudo make install
pre>

您可能需要将 / usr / local / lib 添加到您的 DYLD_LIBRARY_PATH 以确保您的可执行文件运行:

  $ export DYLD_LIBRARY_PATH = / usr / local / lib:$ DYLD_LIBRARY_PATH 

(假设 DYLD_LIBRARY_PATH 如果它是空的,你应该做 export DYLD_LIBRARY_PATH = / usr / local / lib 代替。)



编辑:确定,根据您的意见,看起来这应该工作:

  export CMAKE_INCLUDE_PATH = / usr / local / include 
export CMAKE_LIBRARY_PATH = / usr / local / lib

查看如果cmake找不到包,该怎么办



由于您使用的是Cmake的GUI版本,因此您应该这样做:



打开属性列表编辑器,点击添加子项。对于新项目,输入 CMAKE_INCLUDE_PATH ,对于Type,将其保留为String,对于Value,输入 / usr / local / include 。然后,再次单击添加项目,并为新项目输入 CMAKE_LIBRARY_PATH ,将类型保留为字符串,对于值,输入 / usr / local / lib 。然后将(文件 - >另存为)保存到文件。我建议在您的桌面文件夹中的文件名 a.plist 。然后打开终端(Appilcations - > Utilities - > Terminal)并输入:

  mv〜/ Desktop / a.plist〜 .MacOSX / environment.plist 

之后,退出Xcode和Cmake gui,然后重新启动。这应该工作。请参阅的技术细节,以及更多。


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:

$ CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" make
$ sudo make install

You might need to add /usr/local/lib to your DYLD_LIBRARY_PATH to make sure your executable runs:

$ export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH

(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 do export DYLD_LIBRARY_PATH=/usr/local/lib instead.)

Edit: OK, based on your comments, looks like this should work:

export CMAKE_INCLUDE_PATH=/usr/local/include
export CMAKE_LIBRARY_PATH=/usr/local/lib

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 enter CMAKE_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 filename a.plist in your Desktop folder. Then open a terminal (Appilcations -> Utilities -> Terminal) and type:

mv ~/Desktop/a.plist ~/.MacOSX/environment.plist

After that, quit Xcode and Cmake gui, and restart. That should work. See this for technical details, and this for more.

这篇关于#include&lt; FreeImage.h&gt;未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆