firebase/quickstart-cpp

firebase admob link error

lynx-seu opened this issue · 8 comments

when I add admob by

firebase::admob::Initialize(*app);

I got a linker error

./firebase/admob/client/cpp/src/common.h:42: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::~ReferenceCountedFutureImpl()'
firebase/admob/client/cpp/src/banner_view_android.cc:45: error: undefined reference to 'vtable for firebase::ReferenceCountedFutureImpl'
/Users/xx/Developer/tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
./firebase/admob/client/cpp/src/common.h:42: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::~ReferenceCountedFutureImpl()'
firebase/admob/client/cpp/src/interstitial_ad_android.cc:41: error: undefined reference to 'vtable for firebase::ReferenceCountedFutureImpl'
/Users/xx/Developer/tools/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
./firebase/app/client/cpp/src/reference_counted_future_impl.h:280: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::AllocInternal(int, void_, void ()(void))'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:127: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::BackingFromHandle(unsigned int)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:132: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::SetBackingError(firebase::FutureBackingData_, int, char const_)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:135: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::BackingData(firebase::FutureBackingData_)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:138: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::CompleteHandle(unsigned int)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:280: error: undefined reference to 'firebase::ReferenceCountedFutureImpl::AllocInternal(int, void_, void (_)(void*))'
collect2: error: ld returned 1 exit status

It looks like you're not linking with libapp.a as well.

See
https://github.com/firebase/quickstart-cpp/blob/master/admob/testapp/jni/Android.mk#L43
.

libapp.a contains all of the code common across each Firebase C++ library
so you'll need that.

Also, if you're targeting iOS please make sure you have required pods for
each library in your project
https://firebase.google.com/docs/cpp/setup#dependencies , similarly for
Android https://firebase.google.com/docs/cpp/setup#dependencies_1

Please let us know if this solves your issue.

Cheers,
Stewart

On Fri, Aug 12, 2016 at 4:59 PM, Agnesi notifications@github.com wrote:

when I add admob by

firebase::admob::Initialize(*app);

I got a linker error

./firebase/admob/client/cpp/src/common.h:42: error: undefined reference
to 'firebase::ReferenceCountedFutureImpl::~ReferenceCountedFutureImpl()'
firebase/admob/client/cpp/src/banner_view_android.cc:45: error: undefined
reference to 'vtable for firebase::ReferenceCountedFutureImpl'
/Users/xx/Developer/tools/ndk/toolchains/arm-linux-
androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/
arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the
vtable symbol may be undefined because the class is missing its key
function (see go/missingkeymethod)
./firebase/admob/client/cpp/src/common.h:42: error: undefined reference
to 'firebase::ReferenceCountedFutureImpl::~ReferenceCountedFutureImpl()'
firebase/admob/client/cpp/src/interstitial_ad_android.cc:41: error:
undefined reference to 'vtable for firebase::ReferenceCountedFutureImpl'
/Users/xx/Developer/tools/ndk/toolchains/arm-linux-
androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/
arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: the
vtable symbol may be undefined because the class is missing its key
function (see go/missingkeymethod)
./firebase/app/client/cpp/src/reference_counted_future_impl.h:280: error:
undefined reference to 'firebase::ReferenceCountedFutureImpl::AllocInternal(int,
void_, void (_)(void

))' ./firebase/app/client/cpp/src/reference_counted_future_impl.h:127:
error: undefined reference to
'firebase::ReferenceCountedFutureImpl::BackingFromHandle(unsigned int)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:132: error:
undefined reference to
'firebase::ReferenceCountedFutureImpl::SetBackingError(firebase::FutureBackingData
,
int, char const
)' ./firebase/app/client/cpp/src/reference_counted_future_impl.h:135:
error: undefined reference to
'firebase::ReferenceCountedFutureImpl::BackingData(firebase::FutureBackingData

)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:138: error:
undefined reference to 'firebase::ReferenceCountedFutureImpl::CompleteHandle(unsigned
int)'
./firebase/app/client/cpp/src/reference_counted_future_impl.h:280: error:
undefined reference to 'firebase::ReferenceCountedFutureImpl::AllocInternal(int,
void_, void (_)(void*))'
collect2: error: ld returned 1 exit status


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1, or mute the thread
https://github.com/notifications/unsubscribe-auth/AFw1ROtjcSkZ4p6VfujnSXH8xxEOl3Bgks5qfQjLgaJpZM4JjjPi
.

@stewartmiles
There is no error when I create firebase::App without admob.

I put the firebase_cpp_sdk in my source, and create a Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_app
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libapp.a    
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := firebase_admob
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libadmob.a    
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

and in my app,

LOCAL_CXXFLAGS := -std=c++0x

LOCAL_SHARED_LIBRARIES := libopenal libmpg123 

LOCAL_STATIC_LIBRARIES := libphysfs libvorbis libogg libtheora libmodplug libfreetype libluajit SDL2_static \
                            firebase_app firebase_admob

then in the *.cpp


static int app_ctor(lua_State *L)
{
    printf("app:ctor\n");
    firebase::App **app = 0;
    app = (firebase::App **)lua_newuserdata(L, sizeof(void *));

    firebase::AppOptions ao;
#if defined(__ANDROID__)
    JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
    jobject activity = (jobject) SDL_AndroidGetActivity();
    *app = firebase::App::Create(ao, env, activity);
#else
    *app = firebase::App::Create(ao);
#endif

//firebase::admob::Initialize(*app);

    luaL_getmetatable(L, "firebase_app{mt}");
    lua_setmetatable(L, -2);
    return 1;
}

if put firebase::admob::Initialize(*app), I got a lot linker error.

I tried add libanalytics.a to my app, it works fine by firebase::analytics::Initialize(*app);


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_app
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libapp.a    
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)


include $(CLEAR_VARS)
LOCAL_MODULE := firebase_admob
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libadmob.a    
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_analytics
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libanalytics.a    
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

so I think it's not linking with libapp.a as well.

In application.mk, I changed toolchain from gcc 4.9 to clang

APP_STL := gnustl_static
APP_ABI := armeabi armeabi-v7a
APP_CPPFLAGS := -frtti  
APP_LDFLAGS := -llog -landroid -lz -latomic
APP_PLATFORM := 10
NDK_TOOLCHAIN_VERSION := clang

Can anyone help me for this

Hi Agnesi,

Does it work if you change the order of linking so admob is first? So it
would be:

LOCAL_STATIC_LIBRARIES := libphysfs libvorbis libogg libtheora libmodplug
libfreetype libluajit SDL2_static
* firebase_admob firebase_app*

Jon

On Sat, Aug 13, 2016 at 8:28 PM, Agnesi notifications@github.com wrote:

I tried add libanalytics.a to my app, it works fine by
firebase::analytics::Initialize(*app);

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_app
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libapp.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_admob
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libadmob.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := firebase_analytics
LOCAL_SRC_FILES := libs/android/$(TARGET_ARCH_ABI)/gnustl/libanalytics.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

so I think it's not linking with libapp.a as well.

In application.mk, I changed toolchain from gcc 4.9 to clang

APP_STL := gnustl_static
APP_ABI := armeabi armeabi-v7a
APP_CPPFLAGS := -frtti
APP_LDFLAGS := -llog -landroid -lz -latomic
APP_PLATFORM := 10
NDK_TOOLCHAIN_VERSION := clang

Can anyone help me for this


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH8se7erDcVKqFY-4yILMIlMgkG8gZFvks5qfotKgaJpZM4JjjPi
.

Thank you, It works. @jonsimantov

Hi, @jonsimantov. Thanks for your comment. I've fixed same issues.
But why lib order is so important?

Here's a really in-depth article about why link order of static libraries matters with many C++ build systems: http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking

Thank you for this @jonsimantov ! Saved me from breaking my laptop with a hammer.