Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Header file not found only in specific translation unit

I'm currently stuck on a compilation problem on Android for my app.

I get the following error during the compilation of my native library with 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:

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. 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.

like image 621
JBL Avatar asked Oct 21 '22 01:10

JBL


1 Answers

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.

I found a way to correct this by adding my include path to the LOCAL_EXPORT_C_INCLUDES.

For some reason, the LOCAL_CPPFLAGS aren't used when compiling the wrapper...

like image 131
JBL Avatar answered Oct 27 '22 12:10

JBL