[cmake-developers] CMAKE 3.7 (for Android target) error: crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main’

Roberto Regalino Roberto.Regalino at autodesk.com
Tue Nov 15 09:07:56 EST 2016


Hi
Thank you for the quick response.

>> What generator are you now using?

Right! I forgot to mention this. I am using the  "NMake Makefiles JOM"

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

This is what I thought!
Regalir

-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com] 
Sent: Tuesday, November 15, 2016 8:12 AM
To: Roberto Regalino <Roberto.Regalino at autodesk.com>
Cc: cmake-developers at cmake.org
Subject: Re: [cmake-developers] CMAKE 3.7 (for Android target) error: crtbegin_dynamic.o:crtbrand.c:function _start: error: undefined reference to 'main’

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