warning: relocation against 'Message' in read-only section
-
After resolving the cmake problem I had when using protobuf in a smal test
https://forum.qt.io/topic/154847/make-errors-in-qt-creator-different-to-the-command-line-make/5
I've no encountered a different issue.
I getwarning: relocation against `_ZTVN6google8protobuf7MessageE' in read-only section `.text.
when linking.
What I don't understand is that the cmake files used for my intial protobuf test and the app cmake files are identical as far as the protobuf file generation is concerned, but the test program compiles without errors, while the app doesn't link.
---cmake log for the test[cmake] Running /home/llist/Qt/Tools/CMake/bin/cmake -S /home/llist/QtProjects/ProtobuffTutorial -B /home/llist/QtProjects/build-ProtobuffTutorial-Desktop_Qt_6_6_1_GCC_64bit-Debug -DCMAKE_GENERATOR:STRING=Ninja -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=/home/llist/QtProjects/build-ProtobuffTutorial-Desktop_Qt_6_6_1_GCC_64bit-Debug/.qtc/package-manager/auto-setup.cmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/llist/Qt/6.6.1/gcc_64/bin/qmake -DCMAKE_PREFIX_PATH:PATH=/home/llist/Qt/6.6.1/gcc_64 -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-12 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/x86_64-linux-gnu-g++ -DCMAKE_CXX_FLAGS_INIT:STRING=-DQT_QML_DEBUG in /home/llist/QtProjects/build-ProtobuffTutorial-Desktop_Qt_6_6_1_GCC_64bit-Debug. [cmake] -- The CXX compiler identification is GNU 11.4.0 [cmake] -- Detecting CXX compiler ABI info [cmake] -- Detecting CXX compiler ABI info - done [cmake] -- Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++ - skipped [cmake] -- Detecting CXX compile features [cmake] -- Detecting CXX compile features - done [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success [cmake] -- Found Threads: TRUE [cmake] -- Performing Test HAVE_STDATOMIC [cmake] -- Performing Test HAVE_STDATOMIC - Success [cmake] -- Found WrapAtomic: TRUE [cmake] -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (found version "3.12.4") [cmake] -- Configuring done (0.4s) [cmake] -- Generating done (0.0s) [cmake] -- Build files have been written to: /home/llist/QtProjects/build-ProtobuffTutorial-Desktop_Qt_6_6_1_GCC_64bit-Debug [cmake] [cmake] Elapsed time: 00:00.
--- cmake log for the app
[cmake] Running /home/llist/Qt/Tools/CMake/bin/cmake -S /home/llist/sec1/git/StrawberryRemote -B /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug -DCMAKE_GENERATOR:STRING=Ninja -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=/home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/.qtc/package-manager/auto-setup.cmake -DQT_QMAKE_EXECUTABLE:FILEPATH=/home/llist/Qt/6.6.1/gcc_64/bin/qmake -DCMAKE_PREFIX_PATH:PATH=/home/llist/Qt/6.6.1/gcc_64 -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-12 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/x86_64-linux-gnu-g++ -DCMAKE_CXX_FLAGS_INIT:STRING=-DQT_QML_DEBUG in /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug. [cmake] -- The CXX compiler identification is GNU 11.4.0 [cmake] -- Detecting CXX compiler ABI info [cmake] -- Detecting CXX compiler ABI info - done [cmake] -- Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++ - skipped [cmake] -- Detecting CXX compile features [cmake] -- Detecting CXX compile features - done [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD [cmake] -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success [cmake] -- Found Threads: TRUE [cmake] -- Performing Test HAVE_STDATOMIC [cmake] -- Performing Test HAVE_STDATOMIC - Success [cmake] -- Found WrapAtomic: TRUE [cmake] -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so [cmake] -- Found WrapOpenGL: TRUE [cmake] -- Found XKB: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "1.4.0", minimum required is "0.5.0") [cmake] -- Found WrapVulkanHeaders: /usr/include [cmake] -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (found version "3.12.4") [cmake] -- Configuring done (0.6s) [cmake] -- Generating done (0.0s) [cmake] -- Build files have been written to: /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug [cmake] [cmake] Elapsed time: 00:01.
-- root for the app
cmake_minimum_required(VERSION 3.14) project(StrawberryRemote LANGUAGES CXX) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Core Network Protobuf) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core Network Protobuf) add_subdirectory(proto) add_executable(StrawberryRemote main.cpp mainwindow.cpp mainwindow.h mainwindow.ui connectionstatus.ui connectionstatus.h connectionstatus.cpp controller.h controller.cpp outgoingmsg.h outgoingmsg.cpp incomingmsg.h incomingmsg.cpp connection.h connection.cpp player.h player.cpp player.ui ) target_include_directories(StrawberryRemote PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") target_link_libraries(StrawberryRemote Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Protobuf ${Protobuf_LIBRARIES} Proto ) include(GNUInstallDirs) install(TARGETS StrawberryRemote LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
-- proto for the app
INCLUDE(FindProtobuf) FIND_PACKAGE(Protobuf REQUIRED) include_directories(${Protobuf_INCLUDE_DIR}) protobuf_generate_cpp(PROTO_SRC PROTO_HEADER RemoteMessages.proto) ADD_LIBRARY(Proto ${PROTO_HEADER} ${PROTO_SRC} ) target_sources(Proto PRIVATE RemoteMessages.proto ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(Proto PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
The proto file for the app
syntax = "proto3"; package nw.remote; enum MsgType { MSG_TYPE_UNSPECIFIED = 0; // Client messages MSG_TYPE_CONNECT = 1; MSG_TYPE_DISCONNECT = 2; MSG_TYPE_PLAY = 3; MSG_TYPE_NEXT = 4; MSG_TYPE_PREVIOUS = 5; MSG_TYPE_PAUSE = 6; MSG_TYPE_STOP = 7; } message RequestConnect { bool send_current_song = 1; } enum ReasonDisconnect { REASON_DISCONNECT_SERVER_SHUTDOWN = 0; REASON_DISCONNECT_CLIENT_SHUTDOWN = 1; } message RequestDisconnect { ReasonDisconnect reason_disconnect = 1; } message SongMetadata{ uint32 id = 1; string title = 2; string album = 3; string artist = 4; string albumartist = 5; uint32 track = 6; string stryear = 7; string genre = 8; uint32 playcount = 9; string songlength = 10; } message RequestSongMetadata { SongMetadata song_metadata = 1; } message ResponseSongMetadata { SongMetadata song_metadata = 1; } message RequestNextTrack { bool next = 1; } message RequestPreviousTrack { bool previous = 1; } message RequestPlay { bool play = 1; } message RequestPause { bool pause = 1; } message RequestStop { bool stop = 1; } message Message { uint32 version = 1; MsgType type = 2; RequestSongMetadata request_song_metadata = 3; ResponseSongMetadata response_song_metadata = 4; RequestNextTrack request_next_track = 5; RequestPreviousTrack request_previous_track = 6; RequestPlay request_play = 7; RequestPause request_pause = 8; RequestStop request_stop = 9; RequestConnect request_connect = 10; RequestDisconnect request_disconnect = 11; }
Compiler output
12:50:30: Running steps for project StrawberryRemote... 12:50:30: Starting: "/home/llist/Qt/Tools/CMake/bin/cmake" --build /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug --target all [1/16 76.1/sec] Running cpp protocol buffer compiler on RemoteMessages.proto [2/16 65.7/sec] Automatic MOC and UIC for target Proto [3/16 69.2/sec] Building CXX object proto/CMakeFiles/Proto.dir/Proto_autogen/mocs_compilation.cpp.o [4/16 4.1/sec] Building CXX object proto/CMakeFiles/Proto.dir/RemoteMessages.pb.cc.o [5/16 4.9/sec] Linking CXX static library proto/libProto.a [6/16 4.6/sec] Automatic MOC and UIC for target StrawberryRemote AutoUic: /home/llist/sec1/git/StrawberryRemote/mainwindow.ui: Warning: The name 'layoutWidget' (QWidget) is already in use, defaulting to 'layoutWidget1'. [7/16 3.4/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/incomingmsg.cpp.o [8/16 3.6/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/connection.cpp.o [9/16 3.8/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/player.cpp.o [10/16 4.2/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/main.cpp.o [11/16 4.5/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/StrawberryRemote_autogen/mocs_compilation.cpp.o [12/16 4.8/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/connectionstatus.cpp.o [13/16 5.1/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/outgoingmsg.cpp.o [14/16 5.2/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/controller.cpp.o [15/16 5.4/sec] Building CXX object CMakeFiles/StrawberryRemote.dir/mainwindow.cpp.o [16/16 5.1/sec] Linking CXX executable StrawberryRemote FAILED: StrawberryRemote : && /usr/bin/x86_64-linux-gnu-g++ -DQT_QML_DEBUG -g CMakeFiles/StrawberryRemote.dir/StrawberryRemote_autogen/mocs_compilation.cpp.o CMakeFiles/StrawberryRemote.dir/main.cpp.o CMakeFiles/StrawberryRemote.dir/mainwindow.cpp.o CMakeFiles/StrawberryRemote.dir/connectionstatus.cpp.o CMakeFiles/StrawberryRemote.dir/controller.cpp.o CMakeFiles/StrawberryRemote.dir/outgoingmsg.cpp.o CMakeFiles/StrawberryRemote.dir/incomingmsg.cpp.o CMakeFiles/StrawberryRemote.dir/connection.cpp.o CMakeFiles/StrawberryRemote.dir/player.cpp.o -o StrawberryRemote -Wl,-rpath,/home/llist/Qt/6.6.1/gcc_64/lib: /home/llist/Qt/6.6.1/gcc_64/lib/libQt6Widgets.so.6.6.1 /home/llist/Qt/6.6.1/gcc_64/lib/libQt6Network.so.6.6.1 /home/llist/Qt/6.6.1/gcc_64/lib/libQt6Protobuf.so.6.6.1 /usr/lib/x86_64-linux-gnu/libprotobuf.so proto/libProto.a /home/llist/Qt/6.6.1/gcc_64/lib/libQt6Gui.so.6.6.1 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so /home/llist/Qt/6.6.1/gcc_64/lib/libQt6Core.so.6.6.1 && : /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): warning: relocation against `_ZTVN6google8protobuf7MessageE' in read-only section `.text._ZN6google8protobuf7MessageD2Ev[_ZN6google8protobuf7MessageD5Ev]' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `InitDefaultsscc_info_Message_RemoteMessages_2eproto()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:76: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `InitDefaultsscc_info_RequestConnect_RemoteMessages_2eproto()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:99: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `InitDefaultsscc_info_RequestDisconnect_RemoteMessages_2eproto()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:113: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `InitDefaultsscc_info_RequestNextTrack_RemoteMessages_2eproto()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:127: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `InitDefaultsscc_info_RequestPause_RemoteMessages_2eproto()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:141: undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o):/home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:155: more undefined references to `google::protobuf::internal::VerifyVersion(int, int, char const*)' follow /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `nw::remote::MsgType_descriptor()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:427: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `nw::remote::ReasonDisconnect_descriptor()': /home/llist/sec1/git/build-StrawberryRemote-Desktop_Qt_6_6_1_GCC_64bit-Debug/proto/RemoteMessages.pb.cc:447: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: proto/libProto.a(RemoteMessages.pb.cc.o): in function `nw::remote::RequestConnect::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
Thanks
-
See https://forum.qt.io/topic/154856/error-copy-relocation-against-non-copyable-protected-symbol - I would guess that's the same problem.
-
@Christian-Ehrlicher Thanks, but I fixed this by specifying the library as OBJECT
ADD_LIBRARY(Proto OBJECT
${PROTO_HEADER}
${PROTO_SRC}Mind you, why this is not needed for the test program is still a mystery.
Thanks