Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linking a .proto file using qmake

I have 4 files

message.proto udp.h udp.cpp main.cpp

message.proto is a google protocol buffer file. I am trying to write a protocol buffer and send and receive data using UDP. udp.h and udp.cpp are just classes to implement UDP.

I can write my own makefile and do the needful for this small example. Later I would require to integrate this code into my QT program. I am using qmake -project, qmake to generate the Makefile. I am using Ubuntu 9.10

Could some one tell me the changes I need to make in the .pro file or the Makefile generated by qmake to satisfy the dependencies.

like image 219
user269037 Avatar asked Oct 25 '22 11:10

user269037


1 Answers

Usually you just need to add the respective header and source files to the corresponding HEADERS and SOURCES variables in the .pro file, i.e.

SOURCES += udp.cpp message.pb.cc
HEADERS += udp.h message.pb.h

where I implicity assumed that message.pb.cc and message.pb.h are the files generated by protoc (the protocol buffer compiler). If you additionally want the generated makefile to run protoc for you, you can accomplish that with the system function (http://doc.trolltech.com/4.6/qmake-function-reference.html#system-command).

I hope that helps.

like image 188
Greg S Avatar answered Nov 09 '22 13:11

Greg S