Skip to content

protobuf 3.18.0 broken for Windows when building with MinGW-w64 #8992

@brechtsanders

Description

@brechtsanders

protobuf 3.18.0 fails to build on Windows with MinGW-w64 GCC with the following errors:

R:/winlibs64-10.3.0/protobuf-3.18.0/src/google/protobuf/io/zero_copy_stream_impl.cc:108:28: error: 'F_GETFL' was not declared in this scope
  108 |   int flags = fcntl(file_, F_GETFL);
      |                            ^~~~~~~
R:/winlibs64-10.3.0/protobuf-3.18.0/src/google/protobuf/io/zero_copy_stream_impl.cc:108:15: error: 'fcntl' was not declared in this scope
  108 |   int flags = fcntl(file_, F_GETFL);
      |               ^~~~~
R:/winlibs64-10.3.0/protobuf-3.18.0/src/google/protobuf/io/zero_copy_stream_impl.cc:109:13: error: 'O_NONBLOCK' was not declared in this scope
  109 |   flags &= ~O_NONBLOCK;
      |             ^~~~~~~~~~
R:/winlibs64-10.3.0/protobuf-3.18.0/src/google/protobuf/io/zero_copy_stream_impl.cc:110:16: error: 'F_SETFL' was not declared in this scope
  110 |   fcntl(file_, F_SETFL, flags);
      |                ^~~~~~~

The solution is to replace _MSC_VER with _WIN32 in src/google/protobuf/io/zero_copy_stream_impl.cc.

Apparently a false assumption was made _MSC_VER is always set on the Windows platform, but that is only the case when building with MSVC. On MSVC and MinGW gcc and clang _WIN32 is always defined however.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions