larpon / QtFirebase

An effort to bring Google's Firebase C++ API to Qt + QML
MIT License
284 stars 83 forks source link

Unable to build QtFirebase with Clang #81

Closed daljit97 closed 5 years ago

daljit97 commented 6 years ago

So I decided to switch to Clang as Google deprecated GCC, so I built Qt from the source with the command ./configure xplatform = android-clang and I finally got it working. However, QtFirebase seems not working with Clang as I get many compile errors like the following

/opt/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1149: error: undefined reference to 'std::string::assign(char const*, unsigned int)'
/tmpfs/src/gfile/kokoro_admobandroid/firebase/admob/client/cpp/src/include/firebase/admob/rewarded_video.h:105: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/tmpfs/src/gfile/kokoro_admobandroid/firebase/admob/client/cpp/src/include/firebase/admob/rewarded_video.h:105: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
....
....
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
larpon commented 6 years ago

@daljit97 has Google addressed the issue at their end yet?

daljit97 commented 6 years ago

@Larpon I posted it here https://github.com/firebase/quickstart-cpp/issues/29 but they replied once and then nothing.

Markus87 commented 5 years ago

I just ran into the same issue and I think it should be solved with changing the following: QtFirebase/qtfirebase_target.pri - Line 59 change

QTFIREBASE_SDK_LIBS_PATH = $$QTFIREBASE_SDK_PATH/libs/android/$$ANDROID_TARGET_ARCH/gnustl

to

QTFIREBASE_SDK_LIBS_PATH = $$QTFIREBASE_SDK_PATH/libs/android/$$ANDROID_TARGET_ARCH/c++

ndk clang does use the libc++ stl not the gnu one.

isipisi89 commented 5 years ago

That's correct. You have to use Qt Creator 4.8.+ as well.

isipisi89 commented 5 years ago

Max NDK Version should be ndk-r16b. Do not use the newer one.

Markus87 commented 5 years ago

Yes, I used Qt Creator 4.8 and Qt 5.12. I just test Firebase messaging, I used NDK-r18b. It seems to work.(mostly) Why the limit to ndk-r16b?

larpon commented 5 years ago

We have a nice fix in PR #98 pending from @scivernet - anyone know how we can detect clang in QMake automatically?

Markus87 commented 5 years ago

According to this documentation: http://doc.qt.io/qt-5/qmake-language.html (Platform Scope Values) It says it supports everything that is in the mkspecs directory.(f.e. "Qt\5.12.0\android_armv7\mkspecs")

android-clang{
}

So this should work.

larpon commented 5 years ago

Thanks for the input @Markus87 !

Qt 5.12.0 on Android has some serious crash issues when coming back from a suspended state (should be fixed in 5.12.1+) but beside that I've just merged #98 and modified it a bit in a7f8247

If the assumptions is correct clang should now be auto-detected - please let me now if that's not the case!

To force the clang compatible stl variant set: QTFIREBASE_STL_VARIANT = c++ before including qtfirebase.pri

Re-open if you get any issues :smiley: