google protobuf with Qt



  • Hi,
    is there way to build properly google protocol buffers with Qt?
    downloaded source https://github.com/google/protobuf/releases/tag/v3.2.0
    downloaded compiler https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-win32.zip
    created with protoc files

    proto/bin/commStruct.pb.cc
    proto/bin/commStruct.pb.h
    created lib project with src incuded of google protocol buffers - QtProtobuff.pro
    SOURCES +=
    google/protobuf/wire_format_lite.cc
    google/protobuf/wire_format.cc
    google/protobuf/unknown_field_set.cc
    google/protobuf/text_format.cc
    google/protobuf/service.cc
    google/protobuf/repeated_field.cc
    google/protobuf/reflection_ops.cc
    google/protobuf/message_lite.cc
    google/protobuf/message.cc
    google/protobuf/generated_message_util.cc
    google/protobuf/generated_message_reflection.cc
    google/protobuf/extension_set_heavy.cc
    google/protobuf/extension_set.cc
    google/protobuf/dynamic_message.cc
    google/protobuf/descriptor_database.cc
    google/protobuf/descriptor.pb.cc
    google/protobuf/descriptor.cc
    google/protobuf/compiler/parser.cc
    google/protobuf/compiler/importer.cc
    google/protobuf/io/zero_copy_stream_impl_lite.cc
    google/protobuf/io/zero_copy_stream_impl.cc
    google/protobuf/io/zero_copy_stream.cc
    google/protobuf/io/tokenizer.cc
    google/protobuf/io/printer.cc
    google/protobuf/io/gzip_stream.cc
    google/protobuf/io/coded_stream.cc
    google/protobuf/stubs/substitute.cc
    google/protobuf/stubs/strutil.cc
    google/protobuf/stubs/structurally_valid.cc
    google/protobuf/stubs/once.cc
    google/protobuf/stubs/common.cc

    HEADERS +=
    google/protobuf/wire_format_lite_inl.h
    google/protobuf/wire_format_lite.h
    google/protobuf/wire_format.h
    google/protobuf/unknown_field_set.h
    google/protobuf/text_format.h
    google/protobuf/service.h
    google/protobuf/repeated_field.h
    google/protobuf/reflection_ops.h
    google/protobuf/message_lite.h
    google/protobuf/message.h
    google/protobuf/generated_message_util.h
    google/protobuf/generated_message_reflection.h
    google/protobuf/extension_set.h
    google/protobuf/dynamic_message.h
    google/protobuf/descriptor_database.h
    google/protobuf/descriptor.pb.h
    google/protobuf/descriptor.h
    google/protobuf/compiler/parser.h
    google/protobuf/compiler/importer.h
    google/protobuf/io/zero_copy_stream_impl_lite.h
    google/protobuf/io/zero_copy_stream_impl.h
    google/protobuf/io/zero_copy_stream.h
    google/protobuf/io/tokenizer.h
    google/protobuf/io/printer.h
    google/protobuf/io/gzip_stream.h
    google/protobuf/io/coded_stream_inl.h
    google/protobuf/io/coded_stream.h
    google/protobuf/stubs/substitute.h
    google/protobuf/stubs/strutil.h
    google/protobuf/stubs/stl_util-inl.h
    google/protobuf/stubs/once.h
    google/protobuf/stubs/map-util.h
    google/protobuf/stubs/hash.h
    google/protobuf/stubs/common.h

    SOURCES += qtprotobuff.cpp
    proto/bin/commStruct.pb.cc

    HEADERS += qtprotobuff.h
    proto/bin/commStruct.pb.h

    Build ok

    In desktop app I have add lib QtProtobuff
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-QtProtobuff-Desktop_Qt_5_3_MinGW_32bit-Debug/release/ -lQtProtobuff
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-QtProtobuff-Desktop_Qt_5_3_MinGW_32bit-Debug/debug/ -lQtProtobuff
    else:unix:!macx: LIBS += -L$$PWD/../build-QtProtobuff-Desktop_Qt_5_3_MinGW_32bit-Debug/ -lQtProtobuff

    INCLUDEPATH += $$PWD/../QtProtobuff
    DEPENDPATH += $$PWD/../QtProtobuff

    added #include "qtprotobuff.h"
    commStruct s;

    when build i am getting this error
    : error: undefined reference to google::protobuf::Arena::AllocateAligned(std::type_info const*, unsigned int)' : error: undefined reference togoogle::protobuf::Arena::AddListNode(void*, void ()(void))'
    ...

    please help



  • If it helps here is the script I use to build it on Widows with MSVC2013 and CMake:

    pushd C:\
    set PATH=C:\Program Files (x86)\Git\bin;C:\Program Files\CMake\bin;%PATH%
    CALL "C:\Qt\5.8\msvc2013\bin\qtenv2.bat"
    CALL "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/vcvarsall.bat"
    popd
    echo on
    git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock
    cd gmock
    git clone -b release-1.7.0 https://github.com/google/googletest.git gtest
    cd ..\cmake
    mkdir build
    cd build
    cmake -G "NMake Makefiles"  -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=C:\ProtoBuf -DCMAKE_BUILD_TYPE=DEBUG ../
    nmake
    nmake install
    cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\ProtoBuf -DCMAKE_BUILD_TYPE=RELEASE ../
    nmake
    nmake install
    


  • Thanks for answer!

    How to import protocol buffers in project to be portable with Qt designer on Linux and Windows?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.