Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
brechtsanders opened this issue Sep 16, 2021 · 1 comment · Fixed by microsoft/vcpkg#22369
Closed
Labels
platform related Any issue releated to specific platform or OS windows

Comments

@brechtsanders
Copy link
Contributor

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.

@elharo elharo added windows platform related Any issue releated to specific platform or OS labels Sep 16, 2021
@jinmingyi1998
Copy link

Yes! only this version encounter this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform related Any issue releated to specific platform or OS windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants