Protobuf: identifier "GOOGLE_DCHECK" is undefined

Created on 27 Sep 2019  路  12Comments  路  Source: protocolbuffers/protobuf

Hi,

I am using Visual Studio 2017 Professional and Protocol Buffers V 3.9.1.
I generated the header and source files depending on my proto files. I have multiple proto files but one of them is my "main" proto file which imports the other ones. In the pb.h of my "main" proto file I get the error, that the macro GOOGLE_DCHECK is undefined. I detected the definition of this macro in google\protobuf\stubs\logging.h. The header logging.h is included in my "main" pb.h file implicitly by including google\protobuf\arenastring.h

I detected, that after including google\protobuf\port_def.inc the macro GOOGLE_DCHECK is undefined. Is this a bug or is it my own mistake?

Most helpful comment

I had the same problem but Disabling Precompiled Header works for me.

Project Properties > C/C++ > Precompiled Headers > Not Using Precompiled Headers

All 12 comments

I am also experiencing the same issue after generating my %.pb.h file from protoc.

Getting the same error!

I installed grpc and protobuf via vcpkg, if this makes any difference.

Same problem. First I installed protobuf from gRPC repository's master branch targeting protobuf 3.11.2, then from tag v1.26.0 targeting protobuf 3.8.0. I also tried installing the protobuf 3.11.3 from https://github.com/protocolbuffers/protobuf/releases/tag/v3.11.3

Every time I get the identifier "GOOGLE_DCHECK" is undefined error.

As I said here https://stackoverflow.com/questions/60043400/linking-grpc-on-windows-for-visualc/60073170#60073170 I solved it by linking to WS2_32.lib

But it seems it does not solve the problem for everyone.

I had the same problem but Disabling Precompiled Header works for me.

Project Properties > C/C++ > Precompiled Headers > Not Using Precompiled Headers

I had the same problem but Disabling Precompiled Header works for me.

Project Properties > C/C++ > Precompiled Headers > Not Using Precompiled Headers

Worked like a charm, thank you !

Disabling the pre-compiled headers does not in fact do it for me,

Seems like I can build and compile the generated code but the grpcpp/ includes generate this error for me no matter what I try to do.

I am linking against headers and libraries directly from the repo on a Windows 10 Machine, v1.28.1. I tried using vcpkg but I get the same issue.

I had the same problem but Disabling Precompiled Header works for me.

Project Properties > C/C++ > Precompiled Headers > Not Using Precompiled Headers

this does not work for me... Is there any solution to it yet? @anandolee @rafi-kamal ??

As said here: https://github.com/protocolbuffers/protobuf/issues/6710#issuecomment-582342753
I needed to link to WS2_32.lib in addition to disabling precompiled headers.

Neither of these seem to be resolving the issue for me.

I'm using 3.13 and VS17 and I'm getting this GOOGLE_DCHECK is undefined. I've tried turning off precompiled headers and linking to WS2_32.lib but these solutions haven't worked for me.

I tried to comment lines from first #include <google/protobuf/port_def.inc> to #include <google/protobuf/port_undef.inc> in generated header file.

Error dissapeared and my app seems to work fine, but I'm not sure that this is a good solution.

Was this page helpful?
0 / 5 - 0 ratings