[cmake-developers] CMAKE 3.7 (for Android target) error: crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main’
Brad King
brad.king at kitware.com
Tue Nov 15 08:12:11 EST 2016
On 11/14/2016 04:38 PM, Roberto Regalino wrote:
> still target Android but not using VisualStudio
What generator are you now using?
> So far, I managed to create a new toolchain file containing the following:
>
> set(CMAKE_ANDROID_API 21)
> set(CMAKE_ANDROID_SKIP_ANT_STEP 0)
> set(CMAKE_ANDROID_JAVA_SOURCE_DIR java)
> set(CMAKE_ANDROID_BUILD_SYSTEM GradleBuild)
These are all settings for the Nsight Tegra Visual Studio Edition
generation. See documentation here:
* https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-android
for how to configure the Ninja or Makefile generators with a toolchain
file.
> crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main’
For a purely-native binary created via add_executable then one of the
sources should have "main". For creating an apk then additional steps
are needed IIUC, but I'm not very familiar with them.
> My understanding is that these Gradle steps are responsible for embedding
> the AndroidManifest (that, I’ve been told, will define the ‘main’) and
> generate the apk file from the so.
>
> can anyone confirm if CMake 3.7 does provide the equivalent steps or if
> I need to define them myself?
We don't have first-class support for those steps outside of Nsight Tegra.
They need to be done with add_custom_target/add_custom_command.
Can anyone more familiar with APK generation add more?
-Brad
More information about the cmake-developers
mailing list