0

I'm including the libgvr.so library into my Android.mk by including it in my LOCAL_SRC_FILES:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
        GVR_LIB_PATH :=  $(GVR_DIR)/ndk-beta/lib/android_arm
else
        ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
                GVR_LIB_PATH :=  $(GVR_DIR)/ndk-beta/lib/android_arm64
        else
                $(error Invalid architecture!)
        endif
endif
LOCAL_CPPFLAGS := -std=c++11 -Wall -Wextra
LOCAL_SRC_FILES := \
    foo.cpp \
    bar.cpp \
    $(GVR_LIB_PATH)/libgvr.so
LOCAL_C_INCLUDES := \
        include \
    generated \
        $(GVR_DIR)/ndk-beta/include/vr/gvr/capi/include \
        $(GVR_DIR)/ndk-beta/include
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false

The $GVR_LIB_PATH defined at the beginning paths to the correct directories. However, when compiling and linking my code I get unresolvable symbols for functions I am calling here:

Error:(1155) undefined reference to 'gvr_destroy'
Error:(1299) undefined reference to 'gvr_get_time_point_now'
Error:(1248) undefined reference to 'gvr_get_head_pose_in_start_space'

What is the best way to link against libgvr.so using ndk-build? I apologize in advance if this is just a small naming error somewhere I am missing.

Kadinski
  • 161
  • 14

1 Answers1

1

I didn't account for different architectures as you're trying, but here's what ended up working for me:

include $(CLEAR_VARS)
LOCAL_MODULE := libgvr
LOCAL_SRC_FILES := $(GVR_ANDROID_BASE)/ndk-beta/lib/android_arm/libgvr.so
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_SHARED_LIBRARIES  += libgvr

GVR_ANDROID_BASE points to the directory unpacked from a github clone ZIP archive.

Kaganar
  • 6,540
  • 2
  • 26
  • 59
  • Thanks, was $(GVR_ANDROID_BASE) an absolute path for you? Did you run into any issues with an absolute path in your LOCAL_SRC_FILES? – Kadinski Aug 19 '16 at 00:27
  • $(GVR_ANDROID_BASE) ends up being resolved into an absolute path -- I have a superproject root defined with a relative path, e.g. AbsoluteRoot = $(realpath ../../..), and then GVR_ANDROID_BASE ends up being based on that, e.g. GVR_ANDROID_BASE := $(AbsoluteRoot)/external/gvr – Kaganar Aug 19 '16 at 01:55