FireBase and Qt6
-
@Joshika_Namani said in FireBase and Qt6:
INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_app.a
INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_messaging.aWhat is this? INCLUDEPATH is used to specify directories containing header files.
-
@jsulm
After including all files getting below error:arm64-v8a/main.o:(.data+0x0): undefined reference to `firebase::g_messaging_initializer' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:270: libMessageApp_Version1_arm64-v8a.so] Error 1
-
@Joshika_Namani Please post you current pro file (the whole file) and the whole build log.
-
QT += androidextras INCLUDEPATH = $$PWD/firebase_cpp_sdk/include/firebase/app.h INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_app.a INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_messaging.a QMAKE_INCDIR += android/app/build/intermediates/cmake/debug/obj/arm64-v8a/include QMAKE_INCDIR += android/app/build/intermediates/cmake/debug/obj/armeabi-v7a/include # LIBS += -L$$PWD/firebase_cpp_sdk/libs/android/arm64-v8a \ # -lfirebase_app \ # -lfirebase_messaging
-
@jsulm below is my Build log:
-
@Joshika_Namani said in FireBase and Qt6:
INCLUDEPATH = $$PWD/firebase_cpp_sdk/include/firebase/app.h
INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_app.a
INCLUDEPATH += $$FIREBASE_CPP_SDK_DIR/libs/android/arm64-v8a/libfirebase_messaging.aThis is still wrong... Please fix your pro file first. And post WHOLE pro file, not just part of it.
The first error message you get is quite clear - fix your code.
-
QT += quick core # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp RESOURCES += qml.qrc QT += androidextras INCLUDEPATH = $$PWD/firebase_cpp_sdk/include/ INCLUDEPATH = $$PWD/firebase_cpp_sdk/libs/ QMAKE_INCDIR += android/app/build/intermediates/cmake/debug/obj/arm64-v8a/include QMAKE_INCDIR += android/app/build/intermediates/cmake/debug/obj/armeabi-v7a/include # LIBS += -L$$PWD/firebase_cpp_sdk/libs/android/arm64-v8a \ # -lfirebase_app \ # -lfirebase_messaging # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ android/AndroidManifest.xml \ android/build.gradle \ android/gradle.properties \ android/gradle/wrapper/gradle-wrapper.jar \ android/gradle/wrapper/gradle-wrapper.properties \ android/gradlew \ android/gradlew.bat \ android/res/values/libs.xml ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
-
@Joshika_Namani said in FireBase and Qt6:
# LIBS += -L$$PWD/firebase_cpp_sdk/libs/android/arm64-v8a
# -lfirebase_app
# -lfirebase_messagingWhy did you comment this out?
Did you fix the code? -
@jsulm That part of code fave undefined error, so I have commented that,
first error: there are three create functions , but for android we have to callstatic App* Create(JNIEnv* jni_env, jobject activity);
below app.h code:
#if !FIREBASE_PLATFORM_ANDROID || defined(DOXYGEN) /// @brief Initializes the default firebase::App with default options. /// /// @note This method is specific to non-Android implementations. /// /// @return New App instance, the App should not be destroyed for the /// lifetime of the application. If default options can't be loaded this /// will return null. static App* Create(); #endif // !FIREBASE_PLATFORM_ANDROID || defined(DOXYGEN) #ifndef SWIG // <SWIG> // For Unity, we actually use the simpler, iOS version for both platforms // </SWIG> #if FIREBASE_PLATFORM_ANDROID || defined(DOXYGEN) /// @brief Initializes the default firebase::App with default options. /// /// @note This method is specific to the Android implementation. /// /// @param[in] jni_env JNI environment required to allow Firebase services /// to interact with the Android framework. /// @param[in] activity JNI reference to the Android activity, required to /// allow Firebase services to interact with the Android application. /// /// @return New App instance. The App should not be destroyed for the /// lifetime of the application. If default options can't be loaded this /// will return null. static App* Create(JNIEnv* jni_env, jobject activity); #endif // FIREBASE_PLATFORM_ANDROID || defined(DOXYGEN) #endif // SWIG #if !FIREBASE_PLATFORM_ANDROID || defined(DOXYGEN) /// @brief Initializes the default firebase::App with the given options. /// /// @note This method is specific to non-Android implementations. /// /// Options are copied at initialization time, so changes to the object are /// ignored. /// @param[in] options Options that control the creation of the App. /// /// @return New App instance, the App should not be destroyed for the /// lifetime of the application. static App* Create(const AppOptions& options);
My code:
firebase::App* app = firebase::App::Create();
Error:
27: undefined reference to `firebase::App::Create()'
-
@Joshika_Namani said in FireBase and Qt6:
That part of code fave undefined error, so I have commented that
So, you think you can use these libraries without linking?
You have to link these libraries. If you get "undefined error" then you have to check whether these libraries are compatible with the architecture you're using (arm64-v8a). Please link this libraries and post whole build log if the build fails. -
@Joshika_Namani I wrote before:
"f you get "undefined error" then you have to check whether these libraries are compatible with the architecture you're using (arm64-v8a)"And:
"post whole build log if the build fails" -
@Joshika_Namani Please post the error message you get now
-
After modifying code:
static struct android_app* g_app_state = nullptr; // Get the activity. jobject GetActivity() { return g_app_state->activity->clazz; } JNIEnv* GetJniEnv() { JavaVM* vm = g_app_state->activity->vm; JNIEnv* env; jint result = vm->AttachCurrentThread(&env, nullptr); return result == JNI_OK ? env : nullptr; } void intialize(){ ::firebase::App* app; ::firebase::messaging::PollableListener listener; #if ANDROID app = ::firebase::App::Create(GetJniEnv(), GetActivity()); #else app = ::firebase::App::Create(); #endif
getting below erros:
../../main.cpp:52:11: error: no matching function for call to 'Create' app = ::firebase::App::Create(GetJniEnv(), GetActivity()); ^~~~~~~~~~~~~~~~~~~~~~~ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:538:15: note: candidate function not viable: no known conversion from 'JNIEnv *' (aka '_JNIEnv *') to 'const firebase::AppOptions' for 1st argument static App* Create(const AppOptions& options, const char* name); ^ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:497:15: note: candidate function not viable: requires single argument 'options', but 2 arguments were provided static App* Create(const AppOptions& options); ^ ../../../MessageApp_Version1/firebase_cpp_sdk/include/firebase/app.h:462:15: note: candidate function not viable: requires 0 arguments, but 2 were provided static App* Create(); ^ 1 error generated. make: *** [Makefile:466: arm64-v8a/main.o] Error 1 14:55:32: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
for previous code I got around 444 errors.
-
@Joshika_Namani Isn't the error message quite clear? There is no ::firebase::App::Create overload which takes two parameters of these types. The error message also tells you which 3 overloads are there, use one of them.
-
I tried
app = ::firebase::App::Create(app_options,"app");
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create(firebase::AppOptions const&, char const*)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:17:22: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) ^
for below code:
app = ::firebase::App::Create();
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create()' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:15:38: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
app = ::firebase::App::Create(app_options);
arm64-v8a/main.o: In function `intialize()': /home/joshikanamani/Desktop/NewProjects/MessageApp_Version1/build/Android_Qt_5_15_2_Clang_Multi_Abi-Debug/../../main.cpp:55: undefined reference to `firebase::App::Create(firebase::AppOptions const&)' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:273: libMessageApp_Version1_arm64-v8a.so] Error 1 15:18:04: The process "/home/joshikanamani/Android/ndk/21.3.6528147/prebuilt/linux-x86_64/bin/make" exited with code 2. Error while building/deploying project MessageApp_Version1 (kit: Android Qt 5.15.2 Clang Multi-Abi) When executing step "Make"
-
@Joshika_Namani
This seems to me to indicate that now your code is correct, the compiler finds the necessary matching functions in an included header file, but the link line does not include whatever you are supposed to have as a (legitimate) library (at least for that function) for FireBase apps to link against? But this is not my area, I know no more, just a suggestion. -
@Joshika_Namani For the third time now:
I wrote before:
"f you get "undefined error" then you have to check whether these libraries are compatible with the architecture you're using (arm64-v8a)"And:
"post WHOLE build log if the build fails"Also: are there any other Firebase libraries besides the 3 you're linking?
-
@jsulm
right now, I'm not facing that issue and those libraries are compatible with my architecture(arm64-v8a) and got solved, My issue is with create function example :app = ::firebase::App::Create(app_options,"app");