0

I am building a dynamic library (.so) file for android with around 100 local c files. The files all include a file c_macros.h, but the c_macros.h in question changes for different groups of files. For example, foo0.c and bar0.c need to include c_macros.h in the directory 0/ whereas foo1.c and bar1.c need to include c_macros.h in the directory 1/.

I see that one can define LOCAL_C_INCLUDES for the entirety of a compilation so that all .o files will use those local includes. However, can the LOCAL_C_INCLUDES be specified for a single file (or a group of files) and then change so that the right directories can be included for the right files?

One solution is just to build different .so files depending on which c_macros.h is being used, but this adds an overhead of around 10KB for each .so file, so I'd like to squash everything in one big .so file if possible, but then I'd need to sort out the LOCAL_C_INCLUDES issue.

mikesol
  • 1,177
  • 1
  • 11
  • 20

1 Answers1

0

You can build it into separate static libraries (where you can easily set different LOCAL_C_INCLUDES for each), and just build one single .so file that includes the static libraries. When linking the final .so file, this doesn't incur any extra overhead (the object files from static libraries behave just as normal individual object files).

mstorsjo
  • 12,983
  • 2
  • 39
  • 62