4

I'm developing Qt application on Win 7 (using Windows Qt distro with MinGW included) and I need to use Google's protocol buffers. So I followed this How to build Google's protobuf in Windows using MinGW? and I have managed to build it.

But it was necessary for me to install separately MinGW and MSYS to achieve that.

Is there cleaner way how to built in protobufs in my app just using Qt and it's toolchain ?

Community
  • 1
  • 1
Kousalik
  • 3,111
  • 3
  • 24
  • 46
  • Your question doesn't make sense, Qt doesn't include a compiler. It must be configured to _use_ a compiler that you already have. – Violet Giraffe Mar 14 '14 at 08:00
  • As I wrote above. Qt installer has MinGW included (qt-opensource-windows-x86-mingw48_opengl-5.2.1.exe). It works nicely out of the box. – Kousalik Mar 14 '14 at 08:13

2 Answers2

2

We created new project and added files from protobuf. I can give you my .pro file. Then we included this project to our common project (subdirs)

QT       -= gui

TARGET = protobuf
TEMPLATE = lib
CONFIG += staticlib

# DESTDIR
win32 {
    CONFIG(debug, debug|release): DESTDIR = ../bin/debug
    CONFIG(release, debug|release): DESTDIR = ../bin/release
}
unix {
    CONFIG(debug, debug|release): DESTDIR = ../bin_unix/debug
    CONFIG(release, debug|release): DESTDIR = ../bin_unix/release
}

INCLUDEPATH += ../protobuf

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 \
    config.h

# Turn off ALL warning for the project
win32:CONFIG += warn_off
Serhiy
  • 1,332
  • 1
  • 16
  • 24
  • And what about the ./configure stuff ? It's not necessary ? Why turn off ALL warnings ? – Kousalik Mar 14 '14 at 08:17
  • qmake will do everything for you, you don't need any makefiles, etc anymore. VS gives some warnings, don't whant to see it, I'm sure guys from Google done everything good. – Serhiy Mar 14 '14 at 08:36
  • ok great, that seems to be exactly what I was looking for. I'll give it a try as soon I can get to it and let you know. – Kousalik Mar 14 '14 at 08:49
  • Well? It's exactly five years later. How'd it go? – Oscar Mar 13 '19 at 18:12
  • I found that if you take the cmake file and use global search and replace to get rid of unneeded path prefixes and then add " \" to the end of each line, you can paste the file lists into a .pro file similar to what you have here. Seems to be building fine. – Oscar Mar 13 '19 at 19:40
  • @Oscar It still works, but with huge drawback: it keeps me from moving to the latest Protobuf library version. So I would not say that compiling every time protobuf lib is a good idea, I want to change it: compile lib and have it to link whenever I need. – Serhiy Mar 16 '19 at 20:40
  • @serhiy Thanks for the reply. It turns out that I spoke too soon anyway.. for some reason, I can't use the built protobuf lib. Linkers complain about tons of missing symbols, despite a lot of symbols being in the lib. So I tried building protobuf directly into my project, and got the same "missing symbols" messages. I don't know what the problem is. – Oscar Mar 17 '19 at 19:51
0

An alternative way to build is to use this project: https://github.com/cjh1/protobuf which does not require running ./configure but does require the CMake build system for Windows which can integrate with the MinGW toolchain that comes with Qt. It currently only builds a protobufs as static libraries (not dynamic/shared) and doesn't install header files but I hope eventually those features will be built in.

MSumulong
  • 1,061
  • 2
  • 12
  • 22