简体   繁体   English

仅在特定翻译单元中找不到头文件

[英]Header file not found only in specific translation unit

I'm currently stuck on a compilation problem on Android for my app. 我目前在Android上遇到了针对我的应用的编译问题。

I get the following error during the compilation of my native library with ndk-build : 在使用ndk-build编译我的本机库时出现以下错误:

BackgroundDisplayConfiguration.h:12:23: fatal error: glm/glm.hpp: 
No such file or directory
#include <glm/glm.hpp>
                          ^

What puzzles me is that I have specified a path for this header only library in my Android.mk the following way: 让我感到困惑的是,我已经通过以下方式在Android.mk为此标题库指定了一个路径:

LOCAL_CPPFLAGS += -I../../glm/include

and this path exists and is correct, but moreover if I mess up this path I get the same error in other files that include glm.hpp . 并且这条路径存在并且是正确的,但是如果我搞砸了这条路径,我在包含glm.hpp其他文件中会得到相同的错误。 When the path is correct, only this file yields an error, and I don't understand why. 当路径正确时,只有这个文件会产生错误,我不明白为什么。 Any pointers? 有什么指针吗?

EDIT: Okay, this is even more puzzling. 编辑:好的,这更令人费解。 The include option appear in every compiler command for each file, but not on the compiler command for the big wrapper generated by swig (that outputs my library_native_wrap.o ), and that's where it yields an error... Well, it at least explains the observed behavior. include选项出现在每个文件的每个编译器命令中,但不出现在swig生成的大包装器的编译器命令上(输出我的library_native_wrap.o ),这就是它产生错误的地方......好吧,它至少解释了观察到的行为。

So I found a workaround for this, even though it doesn't feel quite right. 所以我找到了一个解决方法,即使它感觉不太对劲。

Indeed, I found out that when compiling every source of my library, the compiler command actually had the include option, but then, when compiling the output of swig (that big unique c++ wrapper file), the option wasn't there anymore. 实际上,我发现在编译我的库的每个源时,编译器命令实际上都有include选项,但是当编译swig的输出(那个大的唯一c ++包装器文件)时,选项就不再存在了。

I found a way to correct this by adding my include path to the LOCAL_EXPORT_C_INCLUDES . 我找到了一种方法来通过将我的包含路径添加到LOCAL_EXPORT_C_INCLUDES来纠正这个LOCAL_EXPORT_C_INCLUDES

For some reason, the LOCAL_CPPFLAGS aren't used when compiling the wrapper... 出于某种原因,编译包装时不使用LOCAL_CPPFLAGS ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM