I'm following the cpp tutorial on google protocol buffers
I installed Google Protocol Buffers on Ubuntu and compiled the .proto file so I got the pb.h and pb.cc generated files.
I made ReadAddressBook.cpp very minimal. It just creates the proto object and verifies if the version matches.
#include <iostream>
#include <fstream>
#include <string>
#include "address_book.pb.h"
using namespace std;
int main(){
GOOGLE_PROTOBUF_VERIFY_VERSION;
tutorial::AddressBook address_book;
return 0;
}
I compiled it with
g++ -c ReadAddressBook.cpp
(also with g++ -c ReadAddressBook.cpp -lprotobuf -lpthread but it gave the same results)
However when running:
g++ -o ReadAddressBook ReadAddressBook.o
It gave me the references to the google protobuf src was unavailable. Why would this be?
address_book.pb.cc
for compilation and linking. try thisg++ ReadAddressBook.cpp address_book.pb.cc -lprotobuf -lpthread
. – lnmang++ -c ReadAddressBook.cpp address_book.pb.cc
andg++ -o ReadAddressBook ReadAddressBook.o address_book.pb.o -lprotobuf -lpthread
– lnman