Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- g++ -std=c++0x -D__cplusplus=201103L -I/usr/local/include -O0 -g3 -Wall -Wextra -pedantic -c -fmessage-length=0 -MMD -MP -o "Test.o" "Test.cpp"
- g++ -o "test" Test.o -pthread -lprotobuf -lpthread -L/usr/local/lib -pedantic
- */
- #include <string>
- #include <iostream>
- #include <fstream>
- // ProtocolBuffers
- #include "Combined.pb.h"
- using namespace std;
- using namespace AngeeProtobuf;
- void ListUsers(const Presence& p) {
- cout << "USER PRESENCE DATA_SIZE: " << p.data_size() << endl;
- for (int i = 0; i < p.data_size(); i++) {
- const User& u = p.data(i);
- cout << "USER PRESENCE: " << u.username() << ", online: " << u.online() << ", stateChanged: " << u.statechanged() << endl;
- }
- }
- int main(int argc, char* argv[]) {
- if (argc != 2) {
- cerr << "Usage: " << argv[0] << " PRESENCE_PROTO_FILE" << endl;
- return -1;
- }
- Presence p;
- // Read Presence
- fstream input(argv[1], ios::in | ios::binary);
- if (!p.ParseFromIstream(&input)) {
- cerr << "Failed to parse Presence." << endl;
- return -1;
- }
- ListUsers(p);
- }
- martin@meo2:~/protobuf_test$ g++ -std=c++0x -D__cplusplus=201103L -I/usr/local/include -O0 -g3 -Wall -Wextra -pedantic -c -fmessage-length=0 -MMD -MP -o "Test.o" "Test.cpp"
- martin@meo2:~/protobuf_test$ g++ -o "test" Test.o -pthread -lprotobuf -lpthread -L/usr/local/lib -pedantic
- Test.o: In function `main':
- /home/martin/protobuf_test/Test.cpp:31: undefined reference to `AngeeProtobuf::Presence::Presence()'
- /home/martin/protobuf_test/Test.cpp:34: undefined reference to `AngeeProtobuf::Presence::~Presence()'
- /home/martin/protobuf_test/Test.cpp:31: undefined reference to `AngeeProtobuf::Presence::~Presence()'
- collect2: error: ld returned 1 exit status
- martin@meo2:~/protobuf_test$
Advertisement
Add Comment
Please, Sign In to add comment