Eamorr
Eamorr

Reputation: 10012

Google Protocol Buffers. C++ error: ‘google’ has not been declared

I'm trying to get the following simple C++ program to compile:

#include <stdio.h>
#include <stdlib.h>
using google::protobuf;

int main(void){
    printf("Hello\n");
    return 0;
}

I keep getting the following error:

error: ‘google’ has not been declared

I've linked to -lproto and have protobuf-compiler and libprotobuf-dev installed.

I'm totally stuck now.

Anyone have any ideas?

Many thanks in advance,

Upvotes: 2

Views: 3785

Answers (2)

Fred Foo
Fred Foo

Reputation: 363737

You forgot to include the header for Protocol Buffers, so the google namespace is not declared.

Upvotes: 1

Frerich Raabe
Frerich Raabe

Reputation: 94409

You don't include any header which declares the google namespace. You should include the header file generated by the protoc compiler; it pulls in the necessary includes.

Upvotes: 4

Related Questions