1

How can I specify architecture when I build a library?
I need to build a library in armeabi-v7a for an Android project.
I found -march option, so this is my command :

$ gcc -shared -o liballnet.so -fPIC *.c -march=armv7-a

But it doesn't work :

error: unknown target CPU 'armv7-a'

Any ideas?

Hippo
  • 91
  • 1
  • 8
  • 2 options could do: first use gradle + cmake, https://github.com/googlesamples/android-ndk/tree/master/hello-libs, the lib generation example is under gen-libs ( one shared, one static ). the second way to use ndk-build, look at https://github.com/googlesamples/android-ndk/tree/android-mk/two-libs (read through its android.mk); you got to use NDK toolchain to build, not generic gcc for HOST. – Gerry Aug 22 '17 at 06:14
  • Thank you. But I still don't know how to specify architecture when I build a library? – Hippo Aug 23 '17 at 00:17
  • with grade, setting it would be like: defaultConfig.ndk { abiFilters 'armeabi-v7a' }. example is in here: https://github.com/googlesamples/android-ndk/blob/master/hello-libs/app/build.gradle, look for format of abiFilters. those would be passed into cmake --> gcc ( clang is better if you do not mind ). – Gerry Aug 23 '17 at 17:58

0 Answers0