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

"Conflict" between system-wide Googletest install and STP's (macOS) #393

Open
aytey opened this issue Jan 24, 2021 · 0 comments
Open

"Conflict" between system-wide Googletest install and STP's (macOS) #393

aytey opened this issue Jan 24, 2021 · 0 comments
Assignees

Comments

@aytey
Copy link
Member

aytey commented Jan 24, 2021

Description of issue

On a fresh macOS Big Sur install, with Googletest installed installed via Mac Ports, I get errors such as:

../utils/gtest/src/gtest-internal-inl.h:428:11: error: unknown type name 'string'; did you mean 'String'?
  virtual string CurrentStackTrace(int max_depth, int skip_count) = 0;
          ^~~~~~
          String
/opt/local/include/gtest/internal/gtest-string.h:58:18: note: 'String' declared here
class GTEST_API_ String {
                 ^
In file included from ../utils/gtest/src/gtest-all.cc:42:
In file included from ../utils/gtest/src/gtest.cc:135:
../utils/gtest/src/gtest-internal-inl.h:444:11: error: unknown type name 'string'; did you mean 'String'?
  virtual string CurrentStackTrace(int max_depth, int skip_count)
          ^~~~~~
          String
/opt/local/include/gtest/internal/gtest-string.h:58:18: note: 'String' declared here
class GTEST_API_ String {
                 ^
In file included from ../utils/gtest/src/gtest-all.cc:42:
In file included from ../utils/gtest/src/gtest.cc:135:
../utils/gtest/src/gtest-internal-inl.h:644:25: error: no type named 'SetUpTestCaseFunc' in 'testing::Test'; did you mean 'SetUpTestSuiteFunc'?
                        Test::SetUpTestCaseFunc set_up_tc,
                        ^~~~~~~~~~~~~~~~~~~~~~~
                        SetUpTestSuiteFunc
/opt/local/include/gtest/internal/gtest-internal.h:477:7: note: 'SetUpTestSuiteFunc' declared here
using SetUpTestSuiteFunc = void (*)();
      ^

The reason for this is that zlib is installed via MacPorts, so ZLIB_INCLUDE_DIR gets expanded to /opt/local/include. If you have Googletest installed by MacPorts, then you also have gtest/gtest.h in /opt/local/include. Given that STP needs the zlib include dirs, the final compiler invocation looks like:

/Library/Developer/CommandLineTools/usr/bin/c++ \
    -DGTEST_CREATE_SHARED_LIBRARY=1 \
    -D__STDC_LIMIT_MACROS \
    -Dgtest_EXPORTS \
    -I../include \
    -Iinclude \
    -I../lib \
    -I/opt/local/include \               # <-- needed for zlib
    -I/Users/avj/clones/minisat \
    -I../utils/gtest/include \           # <-- needed for path to gtest submodule
    -I../utils/gtest \
    -g3 \
    -ggdb3 \
    -stdlib=libc++ \
    -Wall \
    -Wextra \
    -Wunused \
    -pedantic \
    -Wsign-compare \
    -fno-omit-frame-pointer \
    -Wtype-limits \
    -Wuninitialized \
    -Wno-deprecated \
    -Wstrict-aliasing \
    -Wpointer-arith \
    -Wheader-guard \
    -Wpointer-arith \
    -Wformat-nonliteral \
    -Winit-self \
    -Wparentheses \
    -Wunreachable-code \
    -O2 \
    -g \
    -arch \
    arm64 \
    -isysroot \
    /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk \
    -fPIC \
    -g3 \
    -ggdb3 \
    -stdlib=libc++ \
    -Wall \
    -Wextra \
    -Wunused \
    -pedantic \
    -Wsign-compare \
    -fno-omit-frame-pointer \
    -Wtype-limits \
    -Wuninitialized \
    -Wno-deprecated \
    -Wstrict-aliasing \
    -Wpointer-arith \
    -Wheader-guard \
    -Wpointer-arith \
    -Wformat-nonliteral \
    -Winit-self \
    -Wparentheses \
    -Wunreachable-code \
    -DGTEST_HAS_PTHREAD=1 \
    -g \
    -pthread \
    -O2 \
    -fPIC \
    -std=gnu++14 \
    -MD \
    -MT \
    tests/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o \
    -MF \
    tests/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o.d \
    -o \
    tests/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o \
    -c \
    ../utils/gtest/src/gtest-all.cc

(notice that /opt/local/include is before../utils/gtest/include).

However, inside of ../utils/gtest/src/gtest-all.cc, the code does this:

#include "gtest/gtest.h"

However, because ../utils/gtest/src/gtest/gtest.h does not exist (the correct path should be ../utils/gtest/include/gtest/gtest.h), this then means that we find gtest in /opt/local/include, which then clashes with what's in ../utils/gtest/include, leading to compilation errors.

Temporary workarounds

Temporary workaround 1 uninstall Googletest system-wide.

Temporary workaround 2 Add -DENABLE_TESTING:BOOL=OFF to your cmake invocation.

@aytey aytey self-assigned this Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant