Kevin Depue
Kevin Depue

Reputation: 415

C++ Extensions in Android.mk Files

Is it possible to compile C++ source files with multiple extensions in a single Android.mk file in the ndk? You can modify the C++ extension (which is .cpp by default) via the LOCAL_CPP_EXTENSION variable, but it appears you can only have it set to one single extension (aka, you couldn't have both .cc and .cpp files compiling in the same Android.mk file)..

Thanks in advance!

Upvotes: 1

Views: 4896

Answers (2)

Thiagarajan Hariharan
Thiagarajan Hariharan

Reputation: 466

NDK >= r7 supports multiple values, eg:

LOCAL_CPP_EXTENSION := .cc .cpp .cxx

Do a 'clean' build after modifying LOCAL_CPP_EXTENSION to avoid errors.

Upvotes: 4

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 14009

No. In build/core/build-binary.mk, 'LOCAL_CPP_EXTENSION must be one word only.'

#
# Check LOCAL_CPP_EXTENSION, use '.cpp' by default
#
LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
ifeq ($(LOCAL_CPP_EXTENSION),)
  LOCAL_CPP_EXTENSION := .cpp
else
  ifneq ($(words $(LOCAL_CPP_EXTENSION)),1)
    $(call __ndk_info, LOCAL_CPP_EXTENSION in $(LOCAL_MAKEFILE) must be one word only, not '$(LOCAL_CPP_EXTENSION)')
    $(call __ndk_error, Aborting)
  endif
endif

Upvotes: 2

Related Questions