asked    Zora     2018-10-22       android       60 view        1 Answer

[SOLVED] Create (Cmake) C/C++ Library to Android without Android Studio

My goal is create a external library made in C/C++ which I can import in my Android Project.

I know how to import, I know how to create a library from C/C++ inside the project using JNI, Cmake, etc. But this is not my goal.

For this I'm using small steps, first with a simple library:


#include "gmath.h"

#if defined(__GNUC__) && __GNUC__ >= 4
#define GMATH_EXPORT __attribute__((visibility("default")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
#define GMATH_EXPORT __attribute__((visibility("default")))

GMATH_EXPORT unsigned gpower(unsigned n) {
    return 44;


#ifndef __POWER_HPP__
#define __POWER_HPP__
 * return pow(2, n)
#ifdef __cplusplus
extern "C"
#endif // __cplusplus
       unsigned gpower(unsigned n);

#endif //__POWER_HPP__

What I'm using the create the library: cmake -DCMAKE_TOOLCHAIN_FILE= /Users/vcanato/Library/Android/sdk/cmake/3.6.4111459/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM= /Users/vcanato/Library/Android/sdk/ndk-bundle/ -DANDROID_ABI="arm64-v8a"


cmake_minimum_required(VERSION 3.4.1)


set(CMAKE_TOOLCHAIN_FILE "/Users/vcanato/Library/Android/sdk/cmake/3.6.4111459/android.toolchain.cmake")
set(ANDROID_NDK "/Users/vcanato/Library/Android/sdk/ndk-bundle/")

add_library(gmath STATIC src/gmath.c)

set(distribution_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../distribution")

The problem is, when I use the lipo -info libgmath.aby terminal it show a different ABI:

enter image description here

How can I build this external library to android using the rights parameters?

  1 Answer  

        answered    Wordsworth     2018-10-22      

Use cmake toolchain from ndk, not sdk:

cmake -DCMAKE_TOOLCHAIN_FILE= /Users/vcanato/Library/Android/sdk/ndk-bundle/build/cmake/android.toolchain.cmake  -DCMAKE_MAKE_PROGRAM= /Users/vcanato/Library/Android/sdk/ndk-bundle/ -DANDROID_ABI="arm64-v8a"

Your Answer

 2018-10-22         Monroe

CORS Error when fetching data from Zoho API on React frontend

The company I work at makes use of Biometric attendance, and syncs the data up to Zoho servers for record keeping. I tried to develop a web-app making use of the Zoho People API, which lets me know when I checked in and when my 8.5 hours will be up.I used Create-React-App to develop the same.Now, the API calls work properly in the node server, where I am able to log the data, but when I start a local server using npm start, Chrome is not able to show the data and I get the following error: Failed to load
 node.js                     1 answers                     36 view
 2018-10-22         Quintion

Set node environment variable to dynamic value in npm script

I would like to set an environment variable dynamically in an npm script. I'm using cross-env as I'm developing on Windows and the server is Unix-based. I want to initialize an environment variable with the current date (new Date()) so I can access and render it in my create-react-app:This works (hard-coded string):"scripts": { "start": "cross-env-shell REACT_APP_BUILD_DATE=\"currentDate\" react-scripts-ts start",}Obviously, currentDate shouldn't be a string but the result of following expression: new Date().How can I achieve that? In other words: How can evaluate some reg...
 node.js                     3 answers                     36 view
 2018-10-22         Judith

when I create a react app project with the create reaction app's npm command, my react devTool showing red

I have a doubt, when I create a react app project with the create reaction app's npm command npm init react-app my-app, it opens on the web page, why is my react devTool showing red? I just want to develop version debugging.enter image description here It is because you are in development mode and the dev extension give you a warning saying that is not a production build.This is not a problem if you are developing just make sure that when you deploy you have a production build.See instructions here [XXX]
 reactjs                     1 answers                     38 view