Using google protobuf with Qt Creator
-
@JonB said in Using google protobuf with Qt Creator:
LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
INCLUDEPATH += C:\vcpkg\installed\x64-windows\include\
LIBS += C:\vcpkg\installed\x64-windows\lib\libprotobuf.lib
SOURCES +=
main.cpp
mainwindow.cpp
m.pb.ccHEADERS +=
mainwindow.h
m.pb.hFORMS +=
mainwindow.uiSorry for the same. Even then Im getting the same undefined error faced by the actual questioner.
i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'' -
@VimHar said in Using google protobuf with Qt Creator:
Even then Im getting the same undefined error faced by the actual questioner.
i.e "undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)''Now I do not understand, because this is not the same error at all as you said you were having. You said you got one of:
. :-1: error: cannot find -lprotobuf
Cannot find llibprotouf.libThese errors mean it could not find the library file to link with --- which is why I wanted to get you to type in the full path --- where the error now is that the library file is found, but you have an unresolved reference. Quite different kinds of error.
I think/suspect the lib file is being found but is the wrong version or built with the wrong compiler or something like that.... Please start by answering @jsulm's question with your best information.
-
@VimHar said in Using google protobuf with Qt Creator:
Is this the problem??
Probably.
There should be a linker warning in the build log. -
@VimHar said in Using google protobuf with Qt Creator:
I used vcpkg for installing protobuf and Qt uses MinGw64.
I don't know what "vcpkg" is (MSVC??) but it sounds like a different compiler/linker. MinGW library files end in
.a
not.lib
, maybe that is the cause of the "cannot find library" messages? In any case you need to use the smae compiler/linker for everything. -
Hey,.. Great. I have done re-installing protobuf using Msys following the steps below
https://stackoverflow.com/a/73287395/10432503Now I can able to run using plain g++ command in the terminal.
But when I do the same in QT , the following error occurs
:-1: error: Dwarf Error: Can't find .debug_ranges section.My .pro file
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
INCLUDEPATH += C:/protobuf-3.21.11/src
LIBS += -LC:/protobuf-3.21.11/src/.libs -lprotobuf
SOURCES +=
main.cpp
mainwindow.cpp
m.pb.ccHEADERS +=
mainwindow.h
m.pb.hFORMS +=
mainwindow.uiShould I add anything more.?