That makes sense, but that wouldn't explain why add_subdirectory was "passing" the correct variables when invoking add_subdirectory on ode (so appears to have loaded without problems) but not when invoking add_subdirectory on puredata (so having problems).
Conversation
It could be there is some sort of bug in CMake. Android Studio offers no cmake more recent than 3.10.2.4988404.
Do -Wno-unused-volatile-lvalue -Wno-array-bounds -Wno-undefined-var-template sound relevant? ODE was built with those.
1
Actually, ignore my thought about cmake-- I think I'm using host system CMake not Android SDK CMake. THough that in itself could have interesting effects.
1
The issue is almost certainly that the build system is supposed to be passing -D__ANDROID_API__=21 to communicate that minSdkVersion is 21 but it's passing something else instead. If you set it to that by hand, the problem would go away, but you should figure out what's wrong.
2
Okay.
So, a few observations:
- Upgraded to NDK 22, no apparent change.
- I am confused who the build system should be "passing" this =21 -D to. Clang?
1
- The way CMake (our build system) does Android support is we feed it an android.toolchain.cmake from NDK_HOME and this sets all relevant variables. It doesn't appear to set __ANDROID_API__, nor does our CMakeLists.txt (CMake project config).
1
I cannot vouch for our current system as I did not design it. I maintained the prior build system, which had Gradle invoking CMake. The pure-CMake setup is new. It's possible Gradle read AndroidManifest.xml, saw the minSdkVersion there, and translated that into a CMake define...
1
If this is the case, then this simply means that our new non-Gradle setup would need to have the human specify those AndroidManifest.xml-related defines by hand. But I'm not clear who they should be defined to (to CMake? To toolchain.cmake? To clang?)
1
It does seem real suspicious that -DFORTIFY_SOURCE=2 is being set but ONLY on the .c files that are building wrong, and I have literally no idea where that -D came from because we didn't tell it to do that.
1
You definitely need -D__ANDROID_API__=21 in CPPFLAGS to match your minSdkVersion 21. It's broken overall, but you only happen to be seeing it when _FORTIFY_SOURCE is used because _FORTIFY_SOURCE will automatically use the new symbols introduced for newly fortified functions.
If you run `CPPFLAGS=-D__ANDROID_API__=21 cmake` instead of `cmake`, that may work properly.
I don't understand why it would ever be not enabling _FORTIFY_SOURCE=2 by default unless it's building those files without optimization. It's generally passed by default everywhere.
2
Since you have minSdkVersion 21, Android hides the symbols introduced after API 21 from your app in the linker and there's no fortified sendto available. However, your build system isn't setting __ANDROID_API__=21 so it's building code for the latest API level, probably API 30.
2
Show replies

