Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Link error with qt 5.12



  • When I try to compile my program under Qt 5.12 for Android, I get an avalanche of linkage errors:

    Everything worked well with previous versions of Qt.... What's going on? What's going on?

    Thanx!

    Best regards,

    Franck

    My pro file :

    # Android armeabi-v7a
    	equals(ANDROID_TARGET_ARCH, armeabi-v7a) {
    
                    message("armeabi-v7a")
                    QMAKE_CXXFLAGS_DEBUG += "-fsigned-char -g -O0"
                    QMAKE_CFLAGS_DEBUG += "-fsigned-char -g -O0"
                    QMAKE_LFLAGS_DEBUG += "-O0 -Wl,--allow-multiple-definition"
    
    
                    # TODO: Peut-on changer l'optimisaton ?
                    QMAKE_CXXFLAGS_RELEASE += "-fsigned-char -Ofast -mfloat-abi=softfp -DNDEBUG"
                    QMAKE_CFLAGS_RELEASE += "-fsigned-char -Ofast -mfloat-abi=softfp -DNDEBUG"
                    QMAKE_LFLAGS_RELEASE += "-O1 -Wl,--allow-multiple-definition"
    
                    ANDROID_EXTRA_LIBS = \
                       $$PWD/android/lib/armv7/libcrypto.so \
                       $$PWD/android/lib/armv7/libssl.so
    
    #CONFIG += console
    
                    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
    
                    #ANDROID_PERMISSIONS=
    
                    INCLUDEPATH += ../quazip-0.7.3/quazip
    
    		LIBS += "../freetype2-android-master/Android/obj/local/armeabi-v7a/libfreetype2-static.a"
                    LIBS += "../assimp-4.1.0/lib/libassimp_arm_windows.a"
                    LIBS += "../quazip-0.7.3/lib/armeabi-v7a/libquazip.a"
    	}
    
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/Importer.hpp:648: error: undefined reference to 'std::string::c_str() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/Logger.hpp:243: error: undefined reference to 'std::string::c_str() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/Logger.hpp:249: error: undefined reference to 'std::string::c_str() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/Logger.hpp:255: error: undefined reference to 'std::string::c_str() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:282: error: undefined reference to 'std::string::empty() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:295: error: undefined reference to 'std::allocator<char>::allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:295: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:295: error: undefined reference to 'std::allocator<char>::~allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:295: error: undefined reference to 'std::allocator<char>::~allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:299: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:322: error: undefined reference to 'std::string::empty() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:336: error: undefined reference to 'std::string::empty() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/IOSystem.hpp:351: error: undefined reference to 'std::string::empty() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:69: error: undefined reference to 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Profiler.h:73: error: undefined reference to 'std::chrono::_V2::system_clock::now()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Profiler.h:74: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Profiler.h:74: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Profiler.h:85: error: undefined reference to 'std::chrono::_V2::system_clock::now()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Profiler.h:86: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.h:70: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:154: error: undefined reference to 'std::string::operator=(char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:242: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:252: error: undefined reference to 'std::string::operator+=(std::string const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:403: error: undefined reference to 'std::string::operator=(char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:438: error: undefined reference to 'std::string::operator=(char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:496: error: undefined reference to 'std::string::operator=(char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:585: error: undefined reference to 'std::allocator<char>::allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:585: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:585: error: undefined reference to 'std::allocator<char>::~allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:610: error: undefined reference to 'std::string::operator=(std::string&&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:617: error: undefined reference to 'std::allocator<char>::allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:617: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:617: error: undefined reference to 'std::allocator<char>::~allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:632: error: undefined reference to 'std::string::find_last_of(char, unsigned int) const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:645: error: undefined reference to 'std::string::operator=(std::string&&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:652: error: undefined reference to 'std::allocator<char>::allocator()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:652: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:712: error: undefined reference to 'std::string::operator=(std::string const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:968: error: undefined reference to 'std::string::begin()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:968: error: undefined reference to 'std::string::end()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:968: error: undefined reference to 'std::string::begin()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Importer.cpp:1072: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
    E:\Android\Sdk\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*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:90: error: undefined reference to 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:91: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:90: error: undefined reference to 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:140: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:140: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:110: error: undefined reference to 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::str() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:140: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:140: error: undefined reference to 'std::ostream::operator<<(double)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:140: error: undefined reference to 'std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.tcc:699: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.tcc:700: error: undefined reference to 'std::string::size() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.tcc:700: error: undefined reference to 'std::string::reserve(unsigned int)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.tcc:701: error: undefined reference to 'std::string::append(char const*, unsigned int)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.tcc:702: error: undefined reference to 'std::string::append(std::string const&)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2487: error: undefined reference to 'std::string::append(char const*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2487: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:84: error: undefined reference to 'std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/TinyFormatter.h:126: error: undefined reference to 'std::ostream::operator<<(unsigned int)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2514: error: undefined reference to 'std::string::size() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2514: error: undefined reference to 'std::string::size() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2516: error: undefined reference to 'std::string::data() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2516: error: undefined reference to 'std::string::data() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2516: error: undefined reference to 'std::string::size() const'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/stl_pair.h:113: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/stl_pair.h:152: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/GenericProperty.h:64: error: undefined reference to 'std::string::operator=(std::string const&)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/basic_string.h:2590: error: undefined reference to 'std::string::compare(std::string const&) const'
    E:\Android\Sdk\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&)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/ext/new_allocator.h:127: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\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&)'
    E:\Android\Sdk\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&)'
    E:\Android\Sdk\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&)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/bits/stl_construct.h:75: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string&&)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/tuple:1104: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\include/assimp/types.h:279: error: undefined reference to 'std::string::length() const'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/StdOStreamLogStream.h:93: error: undefined reference to 'std::ostream::flush()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/DefaultLogger.cpp:129: error: undefined reference to 'std::cerr'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/DefaultLogger.cpp:129: error: undefined reference to 'std::cout'
    E:\Android\Sdk\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*)'
    E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\include/iostream:74: error: undefined reference to 'std::ios_base::Init::Init()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/DefaultLogger.cpp:429: error: undefined reference to 'std::ios_base::Init::~Init()'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/Exceptional.h:62: error: undefined reference to 'std::runtime_error::runtime_error(std::string const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/ValidateDataStructure.cpp:93: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned int, std::allocator<char> const&)'
    E:\VisualStudioProjects\MYPROJECTS\assimp-4.1.0\code/ValidateDataStructure.cpp:108: error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned int, std::allocator<char> const&)'
    


  • If i use the flag "-stdlib=libstdc++", the compilation works fine but I have got the message :

    "readelf: Error: Not an ELF file - it has the wrong magic bytes at the start" and the application crashes on startup on the android device...



  • You don't mention your NDK. If you still use v. 10, I'd suggest next trying the new 18b, which should be the most comptible with 5.12



  • I tried with the 10, 17c, 18b versions of NDK but without success. I always get the same link errors.


  • Lifetime Qt Champion

    @Francky033 Are you sure you built for Android?


  • Moderators

    @Francky033 said in Link error with qt 5.12:

    I tried with the 10, 17c, 18b versions of NDK but without success. I always get the same link errors.

    how exactly did you change your NDK that you're linking against? Because this was the issue I had. Took me a while, fidling with QTC, to get it running correctly.

    Don't foget to delete your build folder for a clean rebuild after changing.

    Also keep in mind, if you're using pre compiled libaries, you may have to recompile them, when using 5.12. I run into that with QZXing as part of my project.



  • Yes, I have build for armeabi-v7a. With Qt 5.11.3, everything works well...



  • I recompiled all libraries with Qt 5.12 and the NDK r17b. I deleted the build folders before performing the rebuilds.
    I always get the same link errors.
    Could it be the fact that the compiler changed between version 5.11 and 5.12 of Qt? (gcc ->clang)
    Is it due to a change in the standard library?



  • have found the source of my problem. It was just necessary to link with the static library gnustd....

    I succeeded by adding the line

    LIBS += "E:\Android\Sdk\ndk-bundle\sources\cxx-stl\gnu-libstdc++\4.9\libs\armeabi-v7a\libgnustl_static.a"
    

    to my pro file

    Is there a more elegant way to do this?


Log in to reply