Skip to content

Compiler errors switching from GCC to Clang #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daljit97 opened this issue Jul 31, 2018 · 6 comments
Closed

Compiler errors switching from GCC to Clang #29

daljit97 opened this issue Jul 31, 2018 · 6 comments

Comments

@daljit97
Copy link

So I have a Qt project in which I incorporated Firebase C++ using the wrapper here https://github.com/Larpon/QtFirebase. I decided to switch my compiler from GCC (which was working ok) to Clang as Google deprecated the former, but now I am getting these strange errors:

/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:555: error: undefined reference to 'std::string::assign(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/variant.cc:242: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/variant.cc:293: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:282: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:282: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/variant.cc:359: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:555: error: undefined reference to 'std::string::assign(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/variant.cc:370: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:555: error: undefined reference to 'std::string::assign(std::string const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:555: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/variant.cc:386: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:282: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:282: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/include/firebase/app.h:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/app_android.cc:273: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:555: error: undefined reference to 'std::string::assign(std::string const&)'
/opt/android-sdk/current/ndk-bundle/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_appandroid/firebase/app/client/cpp/src/include/firebase/app.h:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/include/firebase/app.h:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/include/firebase/app.h:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/include/firebase/app.h:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1149: error: undefined reference to 'std::string::assign(char const*, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1149: error: undefined reference to 'std::string::assign(char const*, unsigned int)'
/opt/android-sdk/current/ndk-bundle/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_appandroid/firebase/app/client/cpp/src/util_android.cc:843: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/util_android.cc:840: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/util_android.cc:847: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/util_android.cc:797: error: undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/vector.tcc:69: error: undefined reference to 'std::__throw_length_error(char const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/vector.tcc:69: error: undefined reference to 'std::__throw_length_error(char const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1689: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1697: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1697: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:2442: error: undefined reference to 'std::string::append(unsigned int, char)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:2468: error: undefined reference to 'std::string::append(std::string const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1252: error: undefined reference to 'std::string::insert(unsigned int, std::string const&, unsigned int, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:950: error: undefined reference to 'std::string::append(std::string const&)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/util_android.cc:1635: error: undefined reference to 'std::string::push_back(char)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1426: error: undefined reference to 'std::string::erase(unsigned int, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:1585: error: undefined reference to 'std::__throw_length_error(char const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_vector.h:1585: error: undefined reference to 'std::__throw_length_error(char const*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1175: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1175: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:203: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1726: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:218: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:203: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1894: error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:203: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:814: error: undefined reference to 'std::string::_M_mutate(unsigned int, unsigned int, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1026: error: undefined reference to 'std::string::append(char const*, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:2451: error: undefined reference to 'std::string::append(std::string const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:1026: error: undefined reference to 'std::string::append(char const*, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:950: error: undefined reference to 'std::string::append(std::string const&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:203: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
/tmpfs/src/gfile/kokoro_appandroid/firebase/app/client/cpp/src/app_common.cc:182: error: undefined reference to 'std::string::substr(unsigned int, unsigned int) const'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:592: error: undefined reference to 'std::string::swap(std::string&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:814: error: undefined reference to 'std::string::_M_mutate(unsigned int, unsigned int, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_string.h:814: error: undefined reference to 'std::string::_M_mutate(unsigned int, unsigned int, unsigned int)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1726: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1894: error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1697: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1689: error: undefined reference to 'std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_list.h:1697: error: undefined reference to 'std::__detail::_List_node_base::_M_unhook()'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1894: error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/stl_tree.h:1894: error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
/opt/android-sdk/current/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/functional:2438: error: undefined reference to 'std::__throw_bad_function_call()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried to add this in my build.gradle but it doesn't work:

    ndk{
        toolchain = "clang"

        moduleName = "example"

        stl = "c++_static"

        cppFlags.add("-std=c++11")
        cppFlags.add("-fexceptions")
        cppFlags.add("-frtti")
        cppFlags.add("-latomic")
        ldFlags.add("-latomic")
    }
@a-maurice
Copy link
Contributor

Those errors are indeed odd. It seems like there is possibly a conflict with the ndk version you have, though that is admittedly just a guess. Can you check which version of the ndk you have (you can check /opt/android-sdk/current/ndk-bundle/CHANGELOG.md, which should list it near the top).

Also, have you tried out one of the Quickstart testapps we provide at https://github.com/firebase/quickstart-cpp? They are relatively fast to set up, and recently verified, so it'd be interesting to know if you encounter a similar problem with them.

@daljit97
Copy link
Author

daljit97 commented Aug 2, 2018

@a-maurice the thing is that there is no ndk installed in /opt since that directory is completely empty! I am not even sure where /tmpfs/src/gfile/kokoro_appandroid.... is coming from. I will try that to build the quickstart example. For now I am sticking with gcc (even though that is only a temporary solution)

@larpon
Copy link

larpon commented Aug 7, 2018

It looks like errors coming from the closed source binary lib blobs - they usually have those weird paths. I'm guessing they show the paths from the container they were compiled on.

We (QtFirebase project) haven't tried Clang yet - but it look like it's setup related indeed

@scivernet
Copy link

scivernet commented Dec 7, 2018

I came across a similar problem. It turned out that in QtFirebase in one of the .pri file it is hardcoded to use the "gnustl" versions of the firebase libraries from the firebase sdk. Changing that "gnustl" to "c++" made things work using clang.

To make things a litle bit more flexible I added an extra variable (QTFIREBASE_STL_VARIANT) so that the STL variant to be used can be specified in the app main .pro file (a bit like the QTFIREBASE_SDK_PATH variable). Also issued a pull request for this tiny change, but just wanted to mention it already here as it might be usefull

Update: putting the variable in the main .pro file does not always work, depending on the order in which the .pro files are processed. Changing in the location where the original string was does give the expected results!

@larpon
Copy link

larpon commented Dec 7, 2018

Perfect catch!

@larpon
Copy link

larpon commented Dec 11, 2018

I think - and hope we nailed it with a7f8247

@firebase firebase locked and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants