c++ - Issues compiling Qt project with Google Protocol Buffer -
i building network application qt , protocol buffer. have server, can compiled successfully, , qt client, cannot compiled protocol buffer.
the server built running make
on following makefile
pwd := $(shell pwd) cxx := g++ linker := g++ incdirs := -i. -i$(pwd)/lib -i$(pwd)/lib/protobuf-2.6.1/src libdirs := $(pwd)/lib/protobuf-2.6.1/src/.libs libs := -l protobuf cxxflags := -std=c++11 -pthread -g #-wall -wextra build_dir=build bin := $(build_dir)/bin proto := $(shell bash -c "pwd")/lib/protobuf-2.6.1/src/protoc model_dir := model model_build_dir := build bin := $(build_dir)/bin models := $(shell bash -c "cd $(model_dir) && ls *.proto") models_srcfiles := $(patsubst %.proto, %.pb.cc, $(models)) models_objfiles := $(addprefix $(model_dir)/$(model_build_dir)/, $(patsubst %.cc,%.o,$(models_srcfiles))) incdirs += -i$(model_dir)/$(model_build_dir) server_dir := server server_srcfiles := $(wildcard $(server_dir)/*.cpp) server_objfiles := $(addprefix $(bin)/, $(patsubst %.cpp,%.o,$(server_srcfiles))) server_build := $(build_dir)/server client_dir := client qmake := qmake lib_dir := lib lib_srcfiles := $(wildcard $(lib_dir)/*.cpp) lib_objfiles := $(addprefix $(bin)/, $(patsubst %.cpp,%.o,$(lib_srcfiles))) .phony: init_dir clean client model all: init_dir model $(server_build) run: @export ld_library_path=$$ld_library_path:$(libdirs) && ./build/server run_client: @export ld_library_path=$$ld_library_path:$(libdirs) && ./build/client init_dir: @mkdir -p $(bin)/$(server_dir) $(bin)/$(model_dir) $(model_dir)/$(model_build_dir) $(bin)/$(lib_dir) model: $(addprefix, $(model_dir)/, $(models)) @cd $(model_dir) && \ model in $(models); echo proto compiling $$model; \ $(proto) -i=. --cpp_out=./$(model_build_dir) $$model; done && \ cd $(model_build_dir) && \ modelcc in $(models_srcfiles); echo compiling $$modelcc; $(cxx) $(cxxflags) $(incdirs) -c $$modelcc ; done $(server_build): $(lib_objfiles) $(models_objfiles) $(server_objfiles) $(linker) $^ -l $(libdirs) $(libs) -o $@ $(bin)/$(server_dir)/%.o: $(server_dir)/%.cpp $(cxx) $(cxxflags) $(incdirs) -c $< -o $@ $(bin)/$(lib_dir)/%.o: $(lib_dir)/%.cpp $(cxx) $(cxxflags) $(incdirs) -c $< -o $@ client: @cd $(client_dir) && $(qmake) && $(make) clean: rm -rf $(build_dir) $(model_dir)/$(model_build_dir)/*
the client qt project uses .pro:
qt += core gui config += c++11 greaterthan(qt_major_version, 4): qt += widgets target = client template = app sources += main.cpp\ mainwindow.cpp \ ../model/build/main.model.pb.cc \ ../model/build/guess.model.pb.cc \ ../model/build/jack.model.pb.cc \ ../model/build/system.model.pb.cc \ changename.cpp headers += mainwindow.h \ ../model/build/main.model.pb.h \ ../model/build/guess.model.pb.h \ ../model/build/jack.model.pb.h \ ../model/build/system.model.pb.h \ forms += mainwindow.ui \ destdir=../build objects_dir=../build/bin/client moc_dir=../build/bin/client unix:!macx: libs += -l../lib/protobuf-2.6.1/src/.libs/ -lprotoc includepath += ../lib/protobuf-2.6.1/src/.libs ../lib ../model/build/ dependpath += ../lib/protobuf-2.6.1/src/.libs unix:!macx: pre_targetdeps += ../lib/protobuf-2.6.1/src/.libs/libprotoc.a
the 4 protoc generated files, i.e. ../model/build/*.model.pb.h
, generated make model
.
my issue running make model
alone can compile protocol buffer implementation files. including them sources
, compile them qmake
generated makefile not work.
the error follow:
g++ -c -m64 -pipe -o2 -std=c++0x -wall -w -d_reentrant -fpie -dqt_no_debug -dqt_widgets_lib -dqt_gui_lib -dqt_core_lib -i/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -i. -i../lib/protobuf-2.6.1/src/.libs -i../lib -i../model/build -i/usr/include/qt5 -i/usr/include/qt5/qtwidgets -i/usr/include/qt5/qtgui -i/usr/include/qt5/qtcore -i../build/bin/client -i. -o ../build/bin/client/main.o main.cpp in file included mainwindow.h:6:0, main.cpp:1: ../model/build/main.model.pb.h:12:2: error: #error file generated newer version of protoc #error file generated newer version of protoc ^ ../model/build/main.model.pb.h:13:2: error: #error incompatible protocol buffer headers. please update #error incompatible protocol buffer headers. please update ^ ../model/build/main.model.pb.h:14:2: error: #error headers. #error headers. ^ in file included ../model/build/main.model.pb.h:27:0, mainwindow.h:6, main.cpp:1: ../model/build/jack.model.pb.h:12:2: error: #error file generated newer version of protoc #error file generated newer version of protoc ^ ../model/build/jack.model.pb.h:13:2: error: #error incompatible protocol buffer headers. please update #error incompatible protocol buffer headers. please update ^ ../model/build/jack.model.pb.h:14:2: error: #error headers. #error headers. ^ in file included ../model/build/main.model.pb.h:28:0, mainwindow.h:6, main.cpp:1: ../model/build/system.model.pb.h:12:2: error: #error file generated newer version of protoc #error file generated newer version of protoc ^ ../model/build/system.model.pb.h:13:2: error: #error incompatible protocol buffer headers. please update #error incompatible protocol buffer headers. please update ^ ../model/build/system.model.pb.h:14:2: error: #error headers. #error headers. ^ in file included ../model/build/system.model.pb.h:28:0, ../model/build/main.model.pb.h:28, mainwindow.h:6, main.cpp:1: ../model/build/guess.model.pb.h:12:2: error: #error file generated newer version of protoc #error file generated newer version of protoc ^ ../model/build/guess.model.pb.h:13:2: error: #error incompatible protocol buffer headers. please update #error incompatible protocol buffer headers. please update ^ ../model/build/guess.model.pb.h:14:2: error: #error headers. #error headers. ^ in file included ../model/build/main.model.pb.h:27:0, mainwindow.h:6, main.cpp:1: ../model/build/jack.model.pb.h: in member function ‘void blackjack::request::clear_command()’: ../model/build/jack.model.pb.h:297:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ != &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h: in member function ‘void blackjack::request::set_command(const string&)’: ../model/build/jack.model.pb.h:308:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ == &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h: in member function ‘void blackjack::request::set_command(const char*)’: ../model/build/jack.model.pb.h:316:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ == &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h: in member function ‘void blackjack::request::set_command(const char*, size_t)’: ../model/build/jack.model.pb.h:324:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ == &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h: in member function ‘std::string* blackjack::request::mutable_command()’: ../model/build/jack.model.pb.h:332:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ == &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h: in member function ‘std::string* blackjack::request::release_command()’: ../model/build/jack.model.pb.h:340:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ == &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h:344:45: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ command_ = const_cast< ::std::string*>(&::google::protobuf::internal::getemptystringalreadyinited()); ^ ../model/build/jack.model.pb.h: in member function ‘void blackjack::request::set_allocated_command(std::string*)’: ../model/build/jack.model.pb.h:349:20: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ if (command_ != &::google::protobuf::internal::getemptystringalreadyinited()) { ^ ../model/build/jack.model.pb.h:357:45: error: ‘getemptystringalreadyinited’ not member of ‘google::protobuf::internal’ command_ = const_cast< ::std::string*>(&::google::protobuf::internal::getemptystringalreadyinited()); ^
what problem??
thanks help
Comments
Post a Comment