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

Clang compile on macOS needs -std=c++11 CPPFLAG #59

Closed
mhuttner opened this issue May 20, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@mhuttner
Copy link

commented May 20, 2019

On macOS, after installing protobuf i got the following error:

checking google/protobuf/stubs/common.h usability... no
checking google/protobuf/stubs/common.h presence... yes
configure: WARNING: google/protobuf/stubs/common.h: present but cannot be compiled
configure: WARNING: google/protobuf/stubs/common.h:     check for missing prerequisite headers?
configure: WARNING: google/protobuf/stubs/common.h: see the Autoconf documentation
configure: WARNING: google/protobuf/stubs/common.h:     section "Present But Cannot Be Compiled"
configure: WARNING: google/protobuf/stubs/common.h: proceeding with the compiler's result
checking for google/protobuf/stubs/common.h... no
configure: WARNING: Protobuf headers not found with default CXXFLAGS and CPPFLAGS, manually trying /usr/local/include
configure: WARNING: Unsetting ac_cv_header_google_protobuf_stubs_common_h

because the compile fails with clang++ somewhere in the protobuf code.
Adding -std=c++11 to CPPFLAGS in configure.ac fixes the issue:

## And make sure these flags are used for the tests below.
CPPFLAGS="${protobuf_cxxflags} ${CPPFLAGS} -std=c++11"
CXXFLAGS="${protobuf_cxxflags} ${CXXFLAGS}"
@eddelbuettel

This comment has been minimized.

Copy link
Owner

commented May 20, 2019

We should look into this. Adding C++11 as a default is easy these days. Now I don't have access to a macOS machine, and the rhub likely will not have the protobuf libraries...

@eddelbuettel

This comment has been minimized.

Copy link
Owner

commented May 20, 2019

I checked. We already do:

CXX_STD=CXX11

So I suspect something local at your end. Also note how CRAN has not issues on macOS:

https://cloud.r-project.org/web/checks/check_results_RProtoBuf.html

@mhuttner

This comment has been minimized.

Copy link
Author

commented May 22, 2019

I think compiling the protobuf library is where the flag is missing for me.
While debugging this i tried to compile

#include <google/protobuf/stubs/common.h>
#include <stdio.h>

int main() {
   if (GOOGLE_PROTOBUF_VERSION >= 2001000) {
        printf("ok");
   } else {
        printf("not ok");
   }
}

Which fails with

In file included from tmp.cc:1:
/usr/local/include/google/protobuf/stubs/common.h:186:17: error: expected expression
  OnShutdownRun([](const void* pp) { delete static_cast<const T*>(pp); }, p);
                ^
1 error generated.

without the -std=c++11 flag, and i think that is why i get the
configure: WARNING: google/protobuf/stubs/common.h: present but cannot be compiled warning.

@eddelbuettel

This comment has been minimized.

Copy link
Owner

commented May 22, 2019

That is something entirely different.

I told you that R already makes compilation of the RProtoBuf package use C++11.

You compare to building a main() against libproto*. The two only share use of a library, but there is no other commonality here -- and no issue with the package. So closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.