5

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.

JBL
  • 12,588
  • 4
  • 53
  • 84
  • I don't know about the Android NDK, but maybe it only uses `LOCAL_CPPFLAGS` for only preprocessing, and doesn't add the flags to the compiler flags? Have you tried setting e.g. `LOCAL_CXXFLAGS`? – Some programmer dude Sep 24 '14 at 08:52
  • 1
    @JoachimPileborg Well, the [documentation for the android makefile](http://www.kandroid.org/ndk/docs/ANDROID-MK.html) states that `LOCAL_CXXFLAGS` is an alias for `LOCAL_CPPFLAGS` anyway, and even more that it's bound to be deprecated. What really puzzles me is that it happens just on a specific file, and seems to work for others... – JBL Sep 24 '14 at 08:56
  • Just for the sake of trying, I added my include option to both `LOCAL_CXXFLAGS` and to `LOCAL_CFLAGS` and neither fixes the problem. – JBL Sep 24 '14 at 08:58
  • Use `-v` and check what paths the compiler's searching? – T.C. Sep 24 '14 at 09:03
  • @T.C. Was just doing that, edited the question with my findings. – JBL Sep 24 '14 at 09:06

1 Answers1

3

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

JBL
  • 12,588
  • 4
  • 53
  • 84
  • @jww Haha, I was going to say "In another related thread, someone actually qualified the whole system as _broken_". Then realized [**it was you**](http://stackoverflow.com/questions/25663989/warning-android-mk-non-system-libraries-in-linker-flags/25665219#comment40107927_25665219) in fact... :) – JBL Sep 25 '14 at 07:27