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

qmutex_linux.cpp:multiple definition of 'QBasicMutex::lockInternal(int)'



  • I try to compile and install qt5.13.0 to my arm board(armv8,aarch64) using qt-everywhere-src-5.13.0, but I counted the title's problem, I have no idea what leads to this problem, Anyone please give me some clue on how to solve it, thanks

    rm -f libQt5Core.so.5.13.0 libQt5Core.so libQt5Core.so.5 libQt5Core.so.5.13
    aarch64-linux-gnu-g++ -Wl,--no-undefined -Wl,--version-script,QtCore.version -Wl,-O1 -Wl,--enable-new-dtags -shared -Wl,-soname,libQt5Core.so.5 -o libQt5Core.so.5.13.0 .obj/minimum-linux.o .obj/qstring_compat.o .obj/qabstractanimation.o .obj/qvariantanimation.o .obj/qpropertyanimation.o .obj/qanimationgroup.o .obj/qsequentialanimationgroup.o .obj/qparallelanimationgroup.o .obj/qpauseanimation.o .obj/archdetect.o .obj/qendian.o .obj/qglobal.o .obj/qlibraryinfo.o .obj/qmalloc.o .obj/qnumeric.o .obj/qfloat16.o .obj/qoperatingsystemversion.o .obj/qlogging.o .obj/qrandom.o .obj/qhooks.o .obj/qversiontagging.o .obj/qrunnable.o .obj/qthread.o .obj/qthread_unix.o .obj/qatomic.o .obj/qmutex.o .obj/qmutexpool.o .obj/qreadwritelock.o .obj/qsemaphore.o .obj/qthreadpool.o .obj/qthreadstorage.o .obj/qmutex_linux.o .obj/qwaitcondition_unix.o .obj/qexception.o .obj/qfutureinterface.o .obj/qfuturewatcher.o .obj/qresultstore.o .obj/qarraydata.o .obj/qbitarray.o .obj/qbytearray.o .obj/qbytearraylist.o .obj/qbytearraymatcher.o .obj/qcollator.o .obj/qcryptographichash.o .obj/qdatetime.o .obj/qeasingcurve.o .obj/qfreelist.o .obj/qhash.o .obj/qline.o .obj/qlinkedlist.o .obj/qlist.o .obj/qlocale.o .obj/qlocale_tools.o .obj/qpoint.o .obj/qmap.o .obj/qmargins.o .obj/qmessageauthenticationcode.o .obj/qcontiguouscache.o .obj/qrect.o .obj/qregexp.o .obj/qrefcount.o .obj/qringbuffer.o .obj/qshareddata.o .obj/qsharedpointer.o .obj/qsimd.o .obj/qsize.o .obj/qstring.o .obj/qstringbuilder.o .obj/qstringlist.o .obj/qstringview.o .obj/qtextboundaryfinder.o .obj/qtimeline.o .obj/qunicodetools.o .obj/qvsnprintf.o .obj/qversionnumber.o .obj/qlocale_unix.o .obj/adler32.o .obj/compress.o .obj/crc32.o .obj/deflate.o .obj/gzclose.o .obj/gzlib.o .obj/gzread.o .obj/gzwrite.o .obj/infback.o .obj/inffast.o .obj/inflate.o .obj/inftrees.o .obj/trees.o .obj/uncompr.o .obj/zutil.o .obj/qcollator_posix.o .obj/qtimezone.o .obj/qtimezoneprivate.o .obj/qtimezoneprivate_tz.o .obj/qdatetimeparser.o .obj/qregularexpression.o .obj/qcommandlineoption.o .obj/qcommandlineparser.o .obj/harfbuzz-buffer.o .obj/harfbuzz-gdef.o .obj/harfbuzz-gsub.o .obj/harfbuzz-gpos.o .obj/harfbuzz-impl.o .obj/harfbuzz-open.o .obj/harfbuzz-stream.o .obj/harfbuzz-shaper-all.o .obj/qharfbuzz.o .obj/bignum.o .obj/bignum-dtoa.o .obj/cached-powers.o .obj/diy-fp.o .obj/double-conversion.o .obj/fast-dtoa.o .obj/fixed-dtoa.o .obj/strtod.o .obj/qabstractfileengine.o .obj/qbuffer.o .obj/qdataurl.o .obj/qtldurl.o .obj/qdebug.o .obj/qdir.o .obj/qdiriterator.o .obj/qfile.o .obj/qfiledevice.o .obj/qfileinfo.o .obj/qipaddress.o .obj/qiodevice.o .obj/qlockfile.o .obj/qnoncontiguousbytedevice.o .obj/qstorageinfo.o .obj/qtemporarydir.o .obj/qtemporaryfile.o .obj/qresource.o .obj/qresource_iterator.o .obj/qsavefile.o .obj/qstandardpaths.o .obj/qurl.o .obj/qurlidna.o .obj/qurlquery.o .obj/qurlrecode.o .obj/qfsfileengine.o .obj/qfsfileengine_iterator.o .obj/qfilesystementry.o .obj/qfilesystemengine.o .obj/qfileselector.o .obj/qloggingcategory.o .obj/qloggingregistry.o .obj/qfilesystemwatcher.o .obj/qfilesystemwatcher_polling.o .obj/qfilesystemwatcher_inotify.o .obj/qprocess.o .obj/qprocess_unix.o .obj/qsettings.o .obj/qfsfileengine_unix.o .obj/qfilesystemengine_unix.o .obj/qlockfile_unix.o .obj/qfilesystemiterator_unix.o .obj/forkfd_qt.o .obj/qstandardpaths_unix.o .obj/qstorageinfo_unix.o .obj/qabstractitemmodel.o .obj/qitemselectionmodel.o .obj/qabstractproxymodel.o .obj/qconcatenatetablesproxymodel.o .obj/qidentityproxymodel.o .obj/qsortfilterproxymodel.o .obj/qtransposeproxymodel.o .obj/qstringlistmodel.o .obj/qfactoryinterface.o .obj/qpluginloader.o .obj/qfactoryloader.o .obj/quuid.o .obj/qlibrary.o .obj/qelfparser_p.o .obj/qmachparser.o .obj/qlibrary_unix.o .obj/qabstracteventdispatcher.o .obj/qabstractnativeeventfilter.o .obj/qbasictimer.o .obj/qdeadlinetimer.o .obj/qelapsedtimer.o .obj/qeventloop.o .obj/qcoreapplication.o .obj/qcoreevent.o .obj/qmetaobject.o .obj/qmetatype.o .obj/qmetaobjectbuilder.o .obj/qmimedata.o .obj/qobject.o .obj/qobjectcleanuphandler.o .obj/qsignalmapper.o .obj/qsocketnotifier.o .obj/qtimer.o .obj/qtranslator.o .obj/qvariant.o .obj/qcoreglobaldata.o .obj/qsharedmemory.o .obj/qsystemsemaphore.o .obj/qpointer.o .obj/qmath.o .obj/qsystemerror.o .obj/qtestsupport_core.o .obj/qcore_unix.o .obj/qeventdispatcher_unix.o .obj/qtimerinfo_unix.o .obj/qelapsedtimer_unix.o .obj/qsharedmemory_posix.o .obj/qsharedmemory_systemv.o .obj/qsharedmemory_unix.o .obj/qsystemsemaphore_posix.o .obj/qsystemsemaphore_systemv.o .obj/qsystemsemaphore_unix.o .obj/qutfcodec.o .obj/qlatincodec.o .obj/qsimplecodec.o .obj/qtextcodec.o .obj/qisciicodec.o .obj/qtsciicodec.o .obj/qgb18030codec.o .obj/qjpunicode.o .obj/qeucjpcodec.o .obj/qjiscodec.o .obj/qsjiscodec.o .obj/qeuckrcodec.o .obj/qbig5codec.o .obj/qcborstream.o .obj/qcbordiagnostic.o .obj/qcborvalue.o .obj/qdatastream.o .obj/qjson.o .obj/qjsoncbor.o .obj/qjsondocument.o .obj/qjsonobject.o .obj/qjsonarray.o .obj/qjsonvalue.o .obj/qjsonwriter.o .obj/qjsonparser.o .obj/qtextstream.o .obj/qxmlstream.o .obj/qxmlutils.o .obj/qstatemachine.o .obj/qabstractstate.o .obj/qstate.o .obj/qfinalstate.o .obj/qhistorystate.o .obj/qabstracttransition.o .obj/qsignaltransition.o .obj/qeventtransition.o .obj/qmimedatabase.o .obj/qmimetype.o .obj/qmimemagicrulematcher.o .obj/qmimetypeparser.o .obj/qmimemagicrule.o .obj/qmimeglobpattern.o .obj/qmimeprovider.o .obj/qfloat16tables.o .obj/qrc_mimetypes.o .obj/moc_qtransposeproxymodel.o .obj/moc_qmimetype.o -lpthread -lm /home/firefly/Downloads/build_qt/qtbase/lib/libqtpcre2.a /usr/lib/aarch64-linux-gnu/libdl.so
    .obj/qmutex_linux.o: In function QBasicMutex::lockInternal()': qmutex_linux.cpp:(.text+0x0): multiple definition ofQBasicMutex::lockInternal()'
    .obj/qmutex.o:qmutex.cpp:(.text+0x150): first defined here
    .obj/qmutex_linux.o: In function QBasicMutex::lockInternal(int)': qmutex_linux.cpp:(.text+0x60): multiple definition ofQBasicMutex::lockInternal(int)'
    .obj/qmutex.o:qmutex.cpp:(.text+0x2a8): first defined here
    .obj/qmutex_linux.o: In function QBasicMutex::unlockInternal()': qmutex_linux.cpp:(.text+0x1e0): multiple definition ofQBasicMutex::unlockInternal()'
    .obj/qmutex.o:qmutex.cpp:(.text+0x550): first defined here
    collect2: error: ld returned 1 exit status
    Makefile:1241: recipe for target '../../lib/libQt5Core.so.5.13.0' failed
    make[3]: *** [../../lib/libQt5Core.so.5.13.0] Error 1
    make[3]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase/src/corelib'
    Makefile:226: recipe for target 'sub-corelib-make_first' failed
    make[2]: *** [sub-corelib-make_first] Error 2
    make[2]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase/src'
    Makefile:50: recipe for target 'sub-src-make_first' failed
    make[1]: *** [sub-src-make_first] Error 2
    make[1]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase'
    Makefile:63: recipe for target 'module-qtbase-make_first' failed
    make: *** [module-qtbase-make_first] Error 2

    BTW, my configure is following

    #!/bin/sh
    ../qt-everywhere-src-5.13.0/configure
    -v
    -prefix /usr/local/qt5.13
    -opensource
    -confirm-license
    -shared
    -release
    -make libs
    -xplatform linux-aarch64-gnu-g++
    -no-opengl
    -linuxfb
    -qt-libjpeg
    -qt-libpng
    -qt-zlib
    -no-openssl
    -no-cups
    -no-glib
    -no-iconv
    -no-system-proxies
    -no-separate-debug-info
    -nomake examples -nomake tools -nomake tests
    -no-pkg-config
    -skip qtdeclarative
    -skip qtlocation
    -skip qtpurchasing
    -skip qtwayland
    -skip qtwebchannel
    -skip qtwebengine
    -skip qtwebsockets
    -skip qtwebview
    -skip qtwebglplugin
    -skip qtandroidextras
    -skip qtgamepad
    -skip qtmacextras
    -skip qtwinextras
    -skip qtsensors
    -skip qtconnectivity
    -recheck-all



  • @aha_1980
    Hi, I think the problem is because of the compiler.
    As in qmutex.cpp it directly" #include qmutex_linux.cpp", as a result the content of qmutex_linux.cpp will be part of qmutex.cpp.
    And in the thread.pro, the SOURCES +=qmutex.cpp qmutex_linux.cpp, then during link, the two file have same symbols will be detected.
    When I delete qmutex_linux.cpp from SOURCES, there is no problem any more.


  • Lifetime Qt Champion

    HI @lengjianhanshuang,

    which compiler and version is that?

    Regards



  • @aha_1980
    aarch64-linux-gnu-g++(Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609


  • Lifetime Qt Champion

    @lengjianhanshuang So do you cross-compile or do you compile Qt on your ARM board?

    And to be sure, you are using ARM 64 bit platform?



  • Hi @aha_1980
    I compile qt directly on my ARM board.
    and I'm using ARM 64 bit platform

    firefly@firefly:~/Downloads/build_qt/qtbase/qmake$ uname -a
    Linux firefly 4.4.167 #21 SMP Wed Apr 3 09:30:52 CST 2019 aarch64 aarch64 aarch64 GNU/Linux


    BestRegards



  • @aha_1980
    and the cpu is cortex a72



  • @aha_1980
    This make me really crazy, I am not familiar with compile mechanism, in order to solve the multiple definition,
    I directly comment out the two function(lockInternal() & unlockInternal()) and other relative functions in qmutex.cpp,
    at the same time, I remain only "#include "qmutex_linux.cpp" (comment out mac/window) in qmutex.cpp.

    It is something like:
    A.h
    class A
    {
    public:
    void lockInternal();
    void unlockInternal();
    }

    A.cpp
    //A:: lockInternal() {}
    // A:: unlockInternal() {}
    #include "B.cpp"

    B.cpp
    A::lockInternal() {}
    A::unlockInternal() {}

    when compiling, the multiple definition of lockInternal() & unlockInternal() still pop up.


  • Lifetime Qt Champion

    Hi @lengjianhanshuang,

    according to https://wiki.qt.io/Qt_5.13_Release the version 5.13.1 should be released tomorrow.

    Maybe it's worth to wait one day and see if that release works?

    You might also want to ask your question on the Interest mailing list, which is monitored by the developers. This forum is more user orientated.

    Regards



  • @aha_1980
    thanks for your information, I will use the new one tomorrow, at the same time I will ask through mail about current version,
    thanks again.



  • @aha_1980
    Hi, I think the problem is because of the compiler.
    As in qmutex.cpp it directly" #include qmutex_linux.cpp", as a result the content of qmutex_linux.cpp will be part of qmutex.cpp.
    And in the thread.pro, the SOURCES +=qmutex.cpp qmutex_linux.cpp, then during link, the two file have same symbols will be detected.
    When I delete qmutex_linux.cpp from SOURCES, there is no problem any more.


Log in to reply