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 7823957
In Process

The Archive Base Latest Questions

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

I am trying to build a native daemon on Android. The purpose to to

  • 0

I am trying to build a native daemon on Android. The purpose to to control some specific hardware, and Java applications will be able to communicate to this daemon using sockets.

I have been using cmake meanwhile to compile my libraries, demos and the real daemon (which works fine BTW). I am now trying to do 2 different things:

  1. Build the same apps using ndk-build.
  2. Port the C++ daemon to an Android service, by making JNI calls very similar to the way the c++ daemon works.

As far as I understand, ndk-build cannot make native applications, but only native libraries, which in turn can be loaded by the Java GUI… am I correct? For step1 I don’t really need java (and I have proven it already), but I have yet found a way for ndk-build to spit an elf application.

For reference – I am using cmake, as described here: http://opekar.blogspot.com/2011/06/android-cmake-is-much-easier-in-ndk-r5b.html

This way I can have builds for “normal” linux, and also android using out of source builds. Quite nice hack if you ask me.

  • 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-02T08:25:48+00:00Added an answer on June 2, 2026 at 8:25 am

    As mentioned by @Mārtiņš Možeik in one of the comments, this pice of Android.mk will work:

    LOCAL_PATH       := $(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_MODULE     := my_daemon
    LOCAL_C_INCLUDES := src
    LOCAL_SRC_FILES  := src/daemon.c
    include $(BUILD_EXECUTABLE)
    

    One thing I do notice is that the binary produced by this “makefile” is 130k, while the binary produced by cmake was ~40 kb. This is because I used -s as a C_FLAG and then gcc will strip the produced object on the fly. This can be done later on by calling $NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip or the corresponding strip for your arch.

    As I have not found documentation of this feature on the internet, some more words:

    • This works quite good, no problem here 🙂
    • This must be saved in a file called jni/Android.mk.
    • The code must be saved inside the JNI directory
    • If your code is outside of the jni directory this get ugly, but not impossible. You just need to prefix the code with the corresponding prefixes, don’t forget to modify also the include path. This is left to the reader as an exercise.
    • Still unsure why the code generated from Android build system is larger then the code generated by cmake. I previously said that strip is not called – but it is called before the *.so are copied to the lib directory.
    • Still don’t know how to package that binary into an android package, and not even how to run it (for example when the system is up) without modifying the Android code. I assume I can write a Java service that starts on boot and then execvps the daemon.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying build an App Engine connected Android application and am having some problems
I'm trying to build a plugin that contains some native libraries. The project has
I was trying to build a native android application. When I tried to run
Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
Trying to build a GUI application in Java/Swing. I'm mainly used to painting GUIs
I am trying to build a native client module that uses the improv lib
I'm trying to build a native application that for all intents and purposes is
I am trying to build a simple java program which creates a db file,
I'm using Cygwin/Windows and I'm trying to build a native module for node.js. I
I am trying to build a query for fetching the events from the native

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.