Xcode 4.3.3 找不到任何头文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11127824/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:39:09  来源:igfitidea点击:

Xcode 4.3.3 can't find any header files

xcodeheader-filesgsl

提问by slabofguinness

Up until now I've managed to get Xcode to link to the Gnu Scientific Libraries (GSL) which I've installed under /usr/local/lib/ and with header files under /usr/local/include. Under "Build Phases" > "Link Binary With Libraries" I had added libgsl.a etc. Today, Xcode gives an error message claiming it can't find header files.

到目前为止,我已经设法让 Xcode 链接到我安装在 /usr/local/lib/ 下的 Gnu Scientific Libraries (GSL) 和 /usr/local/include 下的头文件。在“Build Phases”>“Link Binary With Libraries”下,我添加了 libgsl.a 等。今天,Xcode 给出了一条错误消息,声称它找不到头文件。

For example

例如

#include <stdio.h>
#include <gsl/gsl_matrix.h>

int main(int argc, const char * argv[])
{

    printf("Hello, World!\n");
    return 0;
}

results in 'gsl/gsl_matrix.h' file not found. I've tried to change the User Header Search path to no avail. Using gcc main.c -lgsl -lgslcblas on the command line works perfectly. Could anyone tell me what exactly one needs to do to get this to work in Xcode? Also, why has it suddenly stopped working for no apparent reason.

导致找不到“gsl/gsl_matrix.h”文件。我试图更改用户标题搜索路径无济于事。在命令行上使用 gcc main.c -lgsl -lgslcblas 效果很好。谁能告诉我究竟需要做什么才能让它在 Xcode 中工作?另外,为什么它突然无缘无故停止工作。

Many kind thanks.

非常感谢。

回答by Usman Rashid

I had same problem when I upgraded to 4.3.3 with include files installed in my /usr/local/include folder. After some head banging, I discovered that I had to add /usr/local/include to the "Header Search Paths" setting under Search Paths in Project Build Settings. I did NOT have to do that in the previous version of XCode. Don't know why it changed, but hope this works for you.

当我升级到 4.3.3 并在我的 /usr/local/include 文件夹中安装包含文件时,我遇到了同样的问题。经过一番折腾,我发现我必须将 /usr/local/include 添加到项目构建设置中搜索路径下的“标题搜索路径”设置中。我不必在以前版本的 XCode 中这样做。不知道为什么它改变了,但希望这对你有用。

回答by Darson

Thanks for help.

感谢帮助。

In Xcode 4.6 I have to:

在 Xcode 4.6 中,我必须:

  • Change default compiler to: LLVM GCC 4.2
  • 将默认编译器更改为:LLVM GCC 4.2

And add this paths:

并添加此路径:

  • Framework Search Paths: /Library/Frameworks
  • Header Search Paths: /usr/local/include
  • Library Search Paths: /usr/include/lib
  • 框架搜索路径:/Library/Frameworks
  • 标题搜索路径:/usr/local/include
  • 库搜索路径:/usr/include/lib