I'm following the cpp tutorial on google protocol buffers 
<https://developers.google.com/protocol-buffers/docs/cpptutorial> and am 
trying to run the example code.


I successfully installed Google Protocol Buffers on Ubuntu and compiled the 
.proto file so I got the pb.h and pb.cc generated files.


<https://lh3.googleusercontent.com/-bajotUc3OY0/V4wJIea68bI/AAAAAAAAApk/bdTPf063eFwqDoEG0amsVU1ghyN1nWZIACLcB/s1600/temp1.png>

ReadAddressBook.cpp is the main c++ file that uses Google Protocol Buffers 
and I made it very minimal:


#include <iostream>#include <fstream>#include <string>#include 
"address_book.pb.h"using namespace std;
int main(){

 GOOGLE_PROTOBUF_VERIFY_VERSION;

 tutorial::AddressBook address_book;

 cout << "Created Object";
return 0;}


Now using g++ I want to run this. The tutorial never mentioned actually how 
to compile and link these files beyond generating the pb.cc and ph.h files.


So I wrote the commands:


g++ -l /home/{usr}/local/include -L /home/{usr}/local/lib ReadAddressBook.cpp 
address_book.pb.cc -lprotobuf -pthread

g++ -c ReadAddressBook.cpp

g++ -o ReadAddressBook ReadAddressBook.o


And got the error messages:


<https://lh3.googleusercontent.com/-3nAqGWE0xEw/V4wLVuiaSbI/AAAAAAAAAp0/_-rRpcC6d4csMD2nLE93b1XuVdjO_PMPgCLcB/s1600/temp2.png>

Undefined reference to 'google::protobuf::internal' and ect..


How do I link these libraries?



-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to