'filename.h' file not found with angled include, use quotes instead. 问题详解

2023-10-21 22:10

本文主要是介绍'filename.h' file not found with angled include, use quotes instead. 问题详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

http://stackoverflow.com/questions/17465902/use-of-external-c-headers-in-objective-c

下面 有个解释的设置步骤 不过 不正确 好像还是最佳回答吧,正确的设置 为 http://blog.csdn.net/jeffasd/article/details/51043492

In my iOS project I need to use an external library written in C++. The C++ header files are all in one directory.

I've added these C++ headers to my Xcode project, and also specified a header search path (in Build Settings).

The issue is that these C++ headers include each other using < > angle brackets. This results in:

'filename.h' file not found with <angled> include, use "quotes" instead.

The weird thing is that Xcode does not complain about all headers. Also the same header #include'd in one file is fine, while an issue when #include'd in another. I think this is caused by the fact that these headers #include each other.

  1. Why doesn't doesn't the search path work?
  2. Is there a way to resolve this without modifying these header files?

Thanks!

share improve this question
 
 
Do you have the sources and the Xcode project of that C++ library? –  CouchDeveloper  Jul 4 '13 at 8:58
 
@CouchDeveloper No I don't. –  meaning-matters  Jul 4 '13 at 9:01
4 
Does setting the "Always Search User Paths" build setting help? –  Martin R  Jul 4 '13 at 9:16
 
@MartinR Holy smokes, yes! :-) Put it as answer and I will reward. I've removed the -I, nice. Why did -Inot work? –  meaning-matters  Jul 4 '13 at 9:23 

3 Answers

active oldest votes
up vote 12 down vote accepted
#include <bla.h>

is meant for standard library or framework headers, and the search strategy Is different than that used for

#include "bla.h"

See for example

  • What is the difference between #include <filename> and #include "filename"?

As a workaround, you can set the Xcode build setting "Always Search User Paths" to YES.

share improve this answer
 
1 
Note that setting "Always Search User Paths" to YES may cause header issues. It's strongly recommended to set it to NO, and that's the correct way. It's still only there for backward compatibilities. The third party library's headers should be included via angle brackets. –  CouchDeveloper  Jul 4 '13 at 10:14
 
@CouchDeveloper: It was meant as a workaround, but you are right and your answer is problably the better solution. –  Martin R  Jul 4 '13 at 10:52
 
@CouchDeveloper agree that the this setting should be set to NO, but is there anything undesirable setting this setting to YES in the context of building an embedded framework? –  Chris Holloway  Apr 15 '15 at 14:16
up vote 7 down vote

Starting from a "blank" application project:

  1. Create a folder "Libraries" in your application's project - preferable as a sibling to your MyApp.xcodeproj file, but it can be anywhere. Create subfolders for each Configuration (Debug, Release, etc.) and possibly for each architecture (armv7, armv7s, arm64) unless the binary is universal binary archive containing all architectures.

  2. Get the headers of the third party library and the static library binaries (possibly more than one for different platforms, Configurations and architectures) and move them into the "Library" folder into corresponding subfolders (which you may need to create):

    For example, assuming you had a universal binary (armv7, armv7s, arm64) and Debug and Release versions of that library: Now, the folder structure is assumed to be as follows:

    $(SRCROOT)/LibrariesDebug-iphoneosincludeThirdPartythird_party.hh ...libThirdParty.a             Release-iphoneosincludeThirdPartythird_party.hh ...libThirdParty.a             
    MyApp.xcodeproj            
    
  3. "Library Search Paths" Build Setting:

    Drag the "Libraries" folder into your Xcode project. This may automatically create a library search path in the build settings. Please verify this, and if it is not correct, fix it.

    Given the example, add the following library search paths for Debug and Release Configuration:

    Debug: Library Search Paths$(SRCROOT)/Libraries/Debug-iphoneos

    Release: Library Search Paths$(SRCROOT)/Libraries/Release-iphoneos

    You may have different library search paths for particular Configuration and Target platform pairs. Set different path's in the build setting accordingly.

  4. "Header Search Paths" Build Setting:

    Given the example, add the following header search path to the Debug and the Release Configuration:

    Debug: Header Search Paths$(SRCROOT)/Libraries/Debug-iphoneos/include

    Release: Header Search Paths$(SRCROOT)/Libraries/Release-iphoneos/include

    Likewise, you may have different paths for particular Config/Target pairs - although the headers may be the same.

  5. Link your app against the C++ standard library by adding -lc++ to the Other Linker Flagsbuild setting.

  6. Import the header in your files as follows:

     #import <ThirdParty/third_party.hh>
    
share improve this answer
 
 
That helped, since that error was target-dependent in my case. –  Thibault D.  Jan 21 '14 at 7:38
 
Epic, first time I can make the angle includes work with a 3rd party library that I have in my project because I want to patch it. Thanks. –  aledalgrande  Nov 17 '14 at 18:33
up vote 1 down vote

In XCode after setting the "User Header Search Paths" to point to your library's directory, you also have to make sure that a field called "Always Search User Paths" is set to "Yes"

This solved the problem I was having: with <boost/signals2.hpp> file not found with <angled> include, use "quotes" instead.


这篇关于'filename.h' file not found with angled include, use quotes instead. 问题详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/257289

相关文章

Windows 系统下 Nginx 的配置步骤详解

《Windows系统下Nginx的配置步骤详解》Nginx是一款功能强大的软件,在互联网领域有广泛应用,简单来说,它就像一个聪明的交通指挥员,能让网站运行得更高效、更稳定,:本文主要介绍W... 目录一、为什么要用 Nginx二、Windows 系统下 Nginx 的配置步骤1. 下载 Nginx2. 解压

VS配置好Qt环境之后但无法打开ui界面的问题解决

《VS配置好Qt环境之后但无法打开ui界面的问题解决》本文主要介绍了VS配置好Qt环境之后但无法打开ui界面的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 目UKeLvb录找到Qt安装目录中designer.UKeLvBexe的路径找到vs中的解决方案资源

RabbitMQ工作模式中的RPC通信模式详解

《RabbitMQ工作模式中的RPC通信模式详解》在RabbitMQ中,RPC模式通过消息队列实现远程调用功能,这篇文章给大家介绍RabbitMQ工作模式之RPC通信模式,感兴趣的朋友一起看看吧... 目录RPC通信模式概述工作流程代码案例引入依赖常量类编写客户端代码编写服务端代码RPC通信模式概述在R

详解如何使用Python从零开始构建文本统计模型

《详解如何使用Python从零开始构建文本统计模型》在自然语言处理领域,词汇表构建是文本预处理的关键环节,本文通过Python代码实践,演示如何从原始文本中提取多尺度特征,并通过动态调整机制构建更精确... 目录一、项目背景与核心思想二、核心代码解析1. 数据加载与预处理2. 多尺度字符统计3. 统计结果可

Linux基础命令@grep、wc、管道符的使用详解

《Linux基础命令@grep、wc、管道符的使用详解》:本文主要介绍Linux基础命令@grep、wc、管道符的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录grep概念语法作用演示一演示二演示三,带选项 -nwc概念语法作用wc,不带选项-c,统计字节数-

SpringCloud中的@FeignClient注解使用详解

《SpringCloud中的@FeignClient注解使用详解》在SpringCloud中使用Feign进行服务间的调用时,通常会使用@FeignClient注解来标记Feign客户端接口,这篇文章... 在Spring Cloud中使用Feign进行服务间的调用时,通常会使用@FeignClient注解

Java Spring 中的监听器Listener详解与实战教程

《JavaSpring中的监听器Listener详解与实战教程》Spring提供了多种监听器机制,可以用于监听应用生命周期、会话生命周期和请求处理过程中的事件,:本文主要介绍JavaSprin... 目录一、监听器的作用1.1 应用生命周期管理1.2 会话管理1.3 请求处理监控二、创建监听器2.1 Ser

maven中的maven-antrun-plugin插件示例详解

《maven中的maven-antrun-plugin插件示例详解》maven-antrun-plugin是Maven生态中一个强大的工具,尤其适合需要复用Ant脚本或实现复杂构建逻辑的场景... 目录1. 核心功能2. 典型使用场景3. 配置示例4. 关键配置项5. 优缺点分析6. 最佳实践7. 常见问题

JVisualVM之Java性能监控与调优利器详解

《JVisualVM之Java性能监控与调优利器详解》本文将详细介绍JVisualVM的使用方法,并结合实际案例展示如何利用它进行性能调优,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1. JVisualVM简介2. JVisualVM的安装与启动2.1 启动JVisualVM2

Redis中的Lettuce使用详解

《Redis中的Lettuce使用详解》Lettuce是一个高级的、线程安全的Redis客户端,用于与Redis数据库交互,Lettuce是一个功能强大、使用方便的Redis客户端,适用于各种规模的J... 目录简介特点连接池连接池特点连接池管理连接池优势连接池配置参数监控常用监控工具通过JMX监控通过Pr