'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

相关文章

详谈redis跟数据库的数据同步问题

《详谈redis跟数据库的数据同步问题》文章讨论了在Redis和数据库数据一致性问题上的解决方案,主要比较了先更新Redis缓存再更新数据库和先更新数据库再更新Redis缓存两种方案,文章指出,删除R... 目录一、Redis 数据库数据一致性的解决方案1.1、更新Redis缓存、删除Redis缓存的区别二

oracle数据库索引失效的问题及解决

《oracle数据库索引失效的问题及解决》本文总结了在Oracle数据库中索引失效的一些常见场景,包括使用isnull、isnotnull、!=、、、函数处理、like前置%查询以及范围索引和等值索引... 目录oracle数据库索引失效问题场景环境索引失效情况及验证结论一结论二结论三结论四结论五总结ora

element-ui下拉输入框+resetFields无法回显的问题解决

《element-ui下拉输入框+resetFields无法回显的问题解决》本文主要介绍了在使用ElementUI的下拉输入框时,点击重置按钮后输入框无法回显数据的问题,具有一定的参考价值,感兴趣的... 目录描述原因问题重现解决方案方法一方法二总结描述第一次进入页面,不做任何操作,点击重置按钮,再进行下

Mysql 中的多表连接和连接类型详解

《Mysql中的多表连接和连接类型详解》这篇文章详细介绍了MySQL中的多表连接及其各种类型,包括内连接、左连接、右连接、全外连接、自连接和交叉连接,通过这些连接方式,可以将分散在不同表中的相关数据... 目录什么是多表连接?1. 内连接(INNER JOIN)2. 左连接(LEFT JOIN 或 LEFT

解决mybatis-plus-boot-starter与mybatis-spring-boot-starter的错误问题

《解决mybatis-plus-boot-starter与mybatis-spring-boot-starter的错误问题》本文主要讲述了在使用MyBatis和MyBatis-Plus时遇到的绑定异常... 目录myBATis-plus-boot-starpythonter与mybatis-spring-b

Java中switch-case结构的使用方法举例详解

《Java中switch-case结构的使用方法举例详解》:本文主要介绍Java中switch-case结构使用的相关资料,switch-case结构是Java中处理多个分支条件的一种有效方式,它... 目录前言一、switch-case结构的基本语法二、使用示例三、注意事项四、总结前言对于Java初学者

Linux内核之内核裁剪详解

《Linux内核之内核裁剪详解》Linux内核裁剪是通过移除不必要的功能和模块,调整配置参数来优化内核,以满足特定需求,裁剪的方法包括使用配置选项、模块化设计和优化配置参数,图形裁剪工具如makeme... 目录简介一、 裁剪的原因二、裁剪的方法三、图形裁剪工具四、操作说明五、make menuconfig

详解Java中的敏感信息处理

《详解Java中的敏感信息处理》平时开发中常常会遇到像用户的手机号、姓名、身份证等敏感信息需要处理,这篇文章主要为大家整理了一些常用的方法,希望对大家有所帮助... 目录前后端传输AES 对称加密RSA 非对称加密混合加密数据库加密MD5 + Salt/SHA + SaltAES 加密平时开发中遇到像用户的

Springboot使用RabbitMQ实现关闭超时订单(示例详解)

《Springboot使用RabbitMQ实现关闭超时订单(示例详解)》介绍了如何在SpringBoot项目中使用RabbitMQ实现订单的延时处理和超时关闭,通过配置RabbitMQ的交换机、队列和... 目录1.maven中引入rabbitmq的依赖:2.application.yml中进行rabbit

C语言线程池的常见实现方式详解

《C语言线程池的常见实现方式详解》本文介绍了如何使用C语言实现一个基本的线程池,线程池的实现包括工作线程、任务队列、任务调度、线程池的初始化、任务添加、销毁等步骤,感兴趣的朋友跟随小编一起看看吧... 目录1. 线程池的基本结构2. 线程池的实现步骤3. 线程池的核心数据结构4. 线程池的详细实现4.1 初