2

My Application.mk is set to build arm as well as x86 shared libraries:

APP_ABI :- armeabi-v7a x86

I have prebuilt openssl static libraries:

libcrypto_v7a.a libcrypto_x86.a libssl_v7a.a libssl_x86.a 

These files have been copied to jni/inc directory:

Would appreciate your help in setting up Android.mk such that it picks up proper library to link with:

LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_v7a -lssl_v7a 

or

LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_x86 -lssl_x86 

Perhaps there is a $(ARCH) kind of variable defined that I could use to my advantage:

LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ -lcrypto_$(ARCH) -lssl_$(ARCH) 

2 Answers 2

3

What about using ifeq and TARGET_ARCH?

LOCAL_LDLIBS := -llog -L$(LOCAL_PATH)/inc/ ifeq ($(TARGET_ARCH),arm) LOCAL_LDLIBS += -lcrypto_v7a -lssl_v7a else ifeq ($(TARGET_ARCH),x86) LOCAL_LDLIBS += -lcrypto_x86 -lssl_x86 endif endif 
Sign up to request clarification or add additional context in comments.

1 Comment

Wonderful. Thank you for your help. Good to know that TARGET_ARCH macro is available.
3

Another alternative is:

MY_LDLIBS_arm := -lcrypto_v7a -lssl_v7a MY_LDLIBS_x86 := -lcrypto_x86 -lssl_x86 MY_LDLIBS_mips := ... LOCAL_LDLIBS += $(MY_LDLIBS_$(TARGET_ARCH)) 

Which is easier to read and write.

3 Comments

+1 but I had to think for a second and digest which means it isn't trivial.
That's a really good alternative, especially as this notation is becoming the norm in upcoming NDK releases: it's already used in AOSP for the CFLAGS: github.com/android/platform_external_skia/blob/master/…
It is strange that while it is natively supported for CFLAGS, I couldn't find such use for LDLIBS.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.