ERROR: copy relocation against non-copyable protected symbol
-
I am porting Cantata from Qt5 to Qt6.
At the end of the compilation, the linking fails with this error:
/usr/bin/ld: support/libsupport.a(acceleratormanager.cpp.o): copy relocation against non-copyable protected symbol `_ZN9QComboBox16staticMetaObjectE@@Qt_6' in /usr/lib/libQt6Widgets.so.6.6.2 collect2: error: ld returned 1 exit status
I have no idea of what can raise this kind of error (removing traces of QComboBox in the cpp file fixes this error but get me another "copy relocation against..." for another file and other symbol).
Thank you for your insight!
I'm building cantata on an up-to-date archlinux laptop.
In case it's needed, the changes are here: https://github.com/fenuks/cantata/pull/1 -
Hi,
From a quick search, it seems you would need to build your code with the
-fPIC
option enabled. -
-
@SGaist Thank you for the proposition. I made this change and it raised a lot of other issues :
<SNIP> Building CXX object replaygain/CMakeFiles/cantata-replaygain.dir/__/support/thread.cpp.o [ 98%] Linking CXX executable ../cantata-replaygain /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::~FfmpegInput()': ffmpeginput.cpp:(.text+0x328): undefined reference to `QBasicMutex::lockInternal()' /usr/bin/ld: ffmpeginput.cpp:(.text+0x339): undefined reference to `QBasicMutex::unlockInternal()' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::isFloatCodec() const': ffmpeginput.cpp:(.text+0xbb0): undefined reference to `QString::fromLatin1(QByteArrayView)' /usr/bin/ld: ffmpeginput.cpp:(.text+0xc08): undefined reference to `QString::endsWith(QLatin1String, Qt::CaseSensitivity) const' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::FfmpegInput(QString const&)': ffmpeginput.cpp:(.text+0xd9c): undefined reference to `QString::toLocal8Bit_helper(QChar const*, long long)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x10f8): undefined reference to `QBasicMutex::lockInternal()' /usr/bin/ld: ffmpeginput.cpp:(.text+0x110b): undefined reference to `QByteArray::_empty' /usr/bin/ld: ffmpeginput.cpp:(.text+0x113f): undefined reference to `QString::fromLatin1(QByteArrayView)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x11ca): undefined reference to `QString::fromLatin1(QByteArrayView)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x1229): undefined reference to `QString::append(QString const&)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x12a3): undefined reference to `QString::toLatin1_helper(QString const&)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x14ae): undefined reference to `QByteArray::_empty' /usr/bin/ld: ffmpeginput.cpp:(.text+0x14d8): undefined reference to `QBasicMutex::unlockInternal()' /usr/bin/ld: ffmpeginput.cpp:(.text+0x14ee): undefined reference to `QBasicMutex::unlockInternal()' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::readFrames()': ffmpeginput.cpp:(.text+0x16b0): undefined reference to `QByteArray::QByteArray(char const*, long long)' /usr/bin/ld: ffmpeginput.cpp:(.text+0x1b9b): undefined reference to `QByteArray::_empty' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::FfmpegInput(QString const&)': ffmpeginput.cpp:(.text+0x13dc): undefined reference to `QBasicMutex::unlockInternal()' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `QMutex::~QMutex()': ffmpeginput.cpp:(.text._ZN6QMutexD2Ev[_ZN6QMutexD5Ev]+0x15): undefined reference to `QBasicMutex::destroyInternal(QMutexPrivate*)' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::~FfmpegInput() [clone .cold]': ffmpeginput.cpp:(.text.unlikely+0x14): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x2c): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x44): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x5c): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x74): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o:ffmpeginput.cpp:(.text.unlikely+0x8c): more undefined references to `qt_assert(char const*, char const*, int)' follow /usr/bin/ld: CMakeFiles/cantata-replaygain.dir/ffmpeginput.cpp.o: in function `FfmpegInput::readFrames() [clone .cold]': ffmpeginput.cpp:(.text.unlikely+0x32c): undefined reference to `qt_assert_x(char const*, char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x344): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x35c): undefined reference to `qt_assert(char const*, char const*, int)' /usr/bin/ld: ffmpeginput.cpp:(.text.unlikely+0x37b): undefined reference to `qt_assert_x(char const*, char const*, char const*, int)' <SNIP>
it does not seem better
-
I found a add_target_link error in one of the sub-folder CMakeLists.txt file... Stupid me.
Compiles better now.
Could someone explain why the new flag -fPIC is needed in Qt6 and was not in Qt5? And is not needed in other projects ? Thx.
It's otherwise resolved.
-