Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:32:25+00:00 2026-06-02T10:32:25+00:00

I’m writing an Android App fully in C++. Using OpenGL E.S. 2, Android-NDK r7

  • 0

I’m writing an Android App fully in C++. Using OpenGL E.S. 2, Android-NDK r7 (platform-9), OpenJDK, and Ubuntu 12.04.

The issue that I’m running into is that my main library which is supposed to make calls to the engine I’m developing is spitting out “undefined reference to android_main” errors. Why it is doing this I have no idea, but I’m almost positive it has some thing to do with my Android.mk. For whatever reason, I can’t quite figure it out.

While the engine library builds perfectly fine, the main Android.mk which references the files used which make up the actual game isn’t building in the way I’d like it to.

The Goal

-I’d like this to link up with -loptim so it may reference and call functions from the engine as a separate library. Because of this, I should be able to port this engine to various other projects and simply link it. This appears to have been done, though if someone else has a better way of accomplishing this I’m all ears.

-I’d also like to figure out why my android_main is not being referenced, and what can be done to fix it.

Main.cpp

#include "engine/stdafx.hpp"
#include "engine/AppData.hpp"
#include "engine/Engine.hpp"
#include "glm/glm.hpp"

using namespace optim;

void android_main( android_app* application )
{
    AppData appData;
    appData.mApplication = application;
    appData.mGraphicsService = new GraphicsService( application );

    Engine app( &appData );
}

Android.mk

MY_LOCAL_PATH := $(call my-dir)

LOCAL_PATH := $(MY_LOCAL_PATH)

include $(CLEAR_VARS)

include $(LOCAL_PATH)/engine/Android.mk

include $(CLEAR_VARS)

LOCAL_PATH := $(MY_LOCAL_PATH)

LOCAL_CFLAGS    := -I$(LOCAL_PATH)/glm -I$(ANDROID_NDK)/sources/cxx-stl/stlport/stlport -I$(LOCAL_PATH)/ -I$(LOCAL_PATH)/engine
LOCAL_MODULE    := pongdroid 
LOCAL_SRC_FILES := Main.cpp PongDroid.cpp
LOCAL_LDLIBS    := -landroid -llog -lEGL -lGLESv2 -L$(PONGDROID_DEV)/obj/local/armeabi/ -loptim
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue)

Note that -loptim is the shared library of the engine I’m linking the main module to. The problem is that, while it appears to link perfectly fine, the library for this makefile in particular won’t produce a shared_library. Everything else seems to compile just fine, however.

NDK-BUILD

**** Build of configuration Default for project pongdroid ****

ndk-build all 
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : optim <= Engine.cpp
Compile++ thumb  : optim <= Config.cpp
Compile++ thumb  : optim <= GraphicsService.cpp
Compile thumb  : android_native_app_glue <= android_native_app_glue.c
StaticLibrary  : libandroid_native_app_glue.a
StaticLibrary  : libstdc++.a
SharedLibrary  : liboptim.so
./obj/local/armeabi/libandroid_native_app_glue.a(android_native_app_glue.o): In function `android_app_entry':
/home/amsterdam/Android/android-ndk/sources/android/native_app_glue/android_native_app_glue.c:234: undefined reference to `android_main'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/liboptim.so] Error 1

**** Build Finished ****

Update

So, I’ve narrowed down the problem a bit. The issue lies in the fact that the root Android.mk file for some reason seems to be ignoring its own library. What’s even stranger is that when I comment out include $(LOCAL_PATH)/engine/Android.mk, the error output gets worse.

So, I’m posting my engine/Android.mk file for clarity to see if anyone can make sense of this mess…

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_CFLAGS    := -I$(LOCAL_PATH)/
LOCAL_MODULE    := optim
LOCAL_SRC_FILES := Engine.cpp Config.cpp GraphicsService.cpp 
LOCAL_LDLIBS := -landroid -llog -lEGL -lGLESv2
LOCAL_STATIC_LIBRARIES := android_native_app_glue

include $(BUILD_SHARED_LIBRARY)

$(call import-module,android/native_app_glue) 

Update 2

A call to ndk-build pongdroid from the shell.

ndk-build pongdroid
Compile++ thumb  : pongdroid <= Main.cpp
Compile++ thumb  : pongdroid <= PongDroid.cpp
SharedLibrary  : liboptim.so
/home/amsterdam/Programming/Android/pongdroid/obj/local/armeabi/libandroid_native_app_glue.a(android_native_app_glue.o): In function `android_app_entry':
/home/amsterdam/Android/android-ndk/sources/android/native_app_glue/android_native_app_glue.c:234: undefined reference to `android_main'
collect2: ld returned 1 exit status
make: *** [/home/amsterdam/Programming/Android/pongdroid/obj/local/armeabi/liboptim.so] Error 1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:32:28+00:00Added an answer on June 2, 2026 at 10:32 am

    Are you including “android_native_app_glue.h” header in Main.cpp or one of its included headers?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.