1

Android noob here. I am trying to create an OpenGL ES based Android App that would run native code and I'm using CMake to build it.

Now I have a C++ library that I need to include, import and link(.a files) against the Android NDK code. I understand the library needs to be cross compiled for Android, but would it work if I build just Linux binaries (.a files) instead, and link it with it?

Also, the C++ library is built using Windows platforms and CMake, which generates a .lib(static lib version of windows). What's the best way to generate .a files from Windows platforms (static lib version of Linux from Windows)?

Rathnavel
  • 85
  • 1
  • 15

1 Answers1

1

Now I have a C++ library that I need to include, import and link(.a files) against the Android NDK code. I understand the library needs to be cross compiled for Android, but would it work if I build just Linux binaries (.a files) instead, and link it with it?

It wouldn't. This is because simply they are of different platforms. Both of them use same format(.a) but that does not mean they are compatible. For example, they use different standard libraries. So you must cross-compile it for Android.

Also, the C++ library is built using Windows platforms and CMake, which generates a .lib(static lib version of windows). What's the best way to generate .a files from Windows platforms (static lib version of Linux from Windows)?

As your C++ library uses CMake and Android NDK officially support CMake build, this wouldn't be so hard.

You can download Android NDK for Windows. Then try CMake guide. Basically what you should do is passing the toolchain file as a CMake argument(plus some arguments like ABI, API level, ...). So you don't need to edit your CMake file probably.

Hanjoung Lee
  • 2,123
  • 1
  • 12
  • 20