'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

相关文章

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

好题——hdu2522(小数问题:求1/n的第一个循环节)

好喜欢这题,第一次做小数问题,一开始真心没思路,然后参考了网上的一些资料。 知识点***********************************无限不循环小数即无理数,不能写作两整数之比*****************************(一开始没想到,小学没学好) 此题1/n肯定是一个有限循环小数,了解这些后就能做此题了。 按照除法的机制,用一个函数表示出来就可以了,代码如下

hdu1043(八数码问题,广搜 + hash(实现状态压缩) )

利用康拓展开将一个排列映射成一个自然数,然后就变成了普通的广搜题。 #include<iostream>#include<algorithm>#include<string>#include<stack>#include<queue>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#inclu

OpenHarmony鸿蒙开发( Beta5.0)无感配网详解

1、简介 无感配网是指在设备联网过程中无需输入热点相关账号信息,即可快速实现设备配网,是一种兼顾高效性、可靠性和安全性的配网方式。 2、配网原理 2.1 通信原理 手机和智能设备之间的信息传递,利用特有的NAN协议实现。利用手机和智能设备之间的WiFi 感知订阅、发布能力,实现了数字管家应用和设备之间的发现。在完成设备间的认证和响应后,即可发送相关配网数据。同时还支持与常规Sof

购买磨轮平衡机时应该注意什么问题和技巧

在购买磨轮平衡机时,您应该注意以下几个关键点: 平衡精度 平衡精度是衡量平衡机性能的核心指标,直接影响到不平衡量的检测与校准的准确性,从而决定磨轮的振动和噪声水平。高精度的平衡机能显著减少振动和噪声,提高磨削加工的精度。 转速范围 宽广的转速范围意味着平衡机能够处理更多种类的磨轮,适应不同的工作条件和规格要求。 振动监测能力 振动监测能力是评估平衡机性能的重要因素。通过传感器实时监

缓存雪崩问题

缓存雪崩是缓存中大量key失效后当高并发到来时导致大量请求到数据库,瞬间耗尽数据库资源,导致数据库无法使用。 解决方案: 1、使用锁进行控制 2、对同一类型信息的key设置不同的过期时间 3、缓存预热 1. 什么是缓存雪崩 缓存雪崩是指在短时间内,大量缓存数据同时失效,导致所有请求直接涌向数据库,瞬间增加数据库的负载压力,可能导致数据库性能下降甚至崩溃。这种情况往往发生在缓存中大量 k

6.1.数据结构-c/c++堆详解下篇(堆排序,TopK问题)

上篇:6.1.数据结构-c/c++模拟实现堆上篇(向下,上调整算法,建堆,增删数据)-CSDN博客 本章重点 1.使用堆来完成堆排序 2.使用堆解决TopK问题 目录 一.堆排序 1.1 思路 1.2 代码 1.3 简单测试 二.TopK问题 2.1 思路(求最小): 2.2 C语言代码(手写堆) 2.3 C++代码(使用优先级队列 priority_queue)

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

【VUE】跨域问题的概念,以及解决方法。

目录 1.跨域概念 2.解决方法 2.1 配置网络请求代理 2.2 使用@CrossOrigin 注解 2.3 通过配置文件实现跨域 2.4 添加 CorsWebFilter 来解决跨域问题 1.跨域概念 跨域问题是由于浏览器实施了同源策略,该策略要求请求的域名、协议和端口必须与提供资源的服务相同。如果不相同,则需要服务器显式地允许这种跨域请求。一般在springbo

题目1254:N皇后问题

题目1254:N皇后问题 时间限制:1 秒 内存限制:128 兆 特殊判题:否 题目描述: N皇后问题,即在N*N的方格棋盘内放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在同一斜线上。因为皇后可以直走,横走和斜走如下图)。 你的任务是,对于给定的N,求出有多少种合法的放置方法。输出N皇后问题所有不同的摆放情况个数。 输入