xcode 无法将 cv.h 添加到项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14913647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
can't add cv.h to project
提问by user2032083
I'm new in Xcode. And i need a help to add lib to my project. I've downloaded opencv framework. I've added it to my project. In main.h i have:
我是 Xcode 的新手。我需要帮助才能将 lib 添加到我的项目中。我已经下载了 opencv 框架。我已将其添加到我的项目中。在 main.hi 中有:
#include <stdio.h>
#include <cv.h>
#include <highgui.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
}
When i run my project I got an error like this: cv.h not found, highgui.h not found. I check /usr/include via terminal and i saw that cv.h and highgui.h are located there. Tell me somebody what should i do?
当我运行我的项目时,我收到了这样的错误:找不到 cv.h,找不到 highgui.h。我通过终端检查 /usr/include ,我看到 cv.h 和 highgui.h 位于那里。告诉我某人我该怎么办?
采纳答案by Freddy
You have to update your build settings in xcode. the error message is telling you that xcode does not know where to locate these files. There are two settings you need to update in your xcode build settings.
您必须在 xcode 中更新构建设置。错误消息告诉您 xcode 不知道在哪里找到这些文件。您需要在 xcode 构建设置中更新两个设置。
- Library Search Paths
- 图书馆搜索路径
There are a lot of settings in xcode. To reduce the number of fields you have to search through use the search box in the top right hand corner. If you type in Libraryyou will see a section title search pathsthat has the setting Library Search Paths. Update that field with the location of your library headers. The most common place is /usr/local/lib.
xcode 中有很多设置。要减少您必须搜索的字段数量,请使用右上角的搜索框。如果您输入Library,您将看到一个部分标题搜索路径,其中设置了Library Search Paths。使用库标题的位置更新该字段。最常见的地方是/usr/local/lib。
- Header Search Paths
- 标题搜索路径
Just like step 1, you can reduce the number of options xcode displays by using the search box. Search for Headerand you will see a section labeled Search Pathswith the option of Header Search Paths. Update that field with the location of your library headers.
就像步骤 1 一样,您可以使用搜索框减少 xcode 显示的选项数量。搜索标题,您将看到一个标有搜索路径的部分,其中包含标题搜索路径选项。使用库标题的位置更新该字段。
回答by Guru
try
尝试
#include <opencv/cv.h>
OR
#include <opencv2/opencv.hpp>
For more information about OpenCV installation - Click Here
有关 OpenCV 安装的更多信息 -单击此处
回答by Matej Serbec
try this:
尝试这个:
#include <opencv/cv.h>
#include <opencv/highgui.h>
if this still does not work for you try to install opencv with MacPorts. You can find module on this link: https://www.macports.org/ports.php?by=library&substr=opencv
如果这仍然对您不起作用,请尝试使用 MacPorts 安装 opencv。您可以在此链接上找到模块:https: //www.macports.org/ports.php?by=library&substr=opencv
回答by iluvcapra
Make sure the installed location for your OpenCV headers is in your user header search path in Xcode. You can set this either in the project settings or the build settings for your target.
确保 OpenCV 头文件的安装位置在 Xcode 中的用户头文件搜索路径中。您可以在项目设置或目标的构建设置中进行设置。