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

Tests fail to compile: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_' #1338

Closed
yurivict opened this issue Jul 30, 2022 · 4 comments
Closed

Comments

@yurivict
Copy link

yurivict commented Jul 30, 2022

clang++ -o test -I.. -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fno-omit-frame-pointer  -isystem /usr/local/include  test.cc include_httplib.cc -fstack-protector-strong -L/usr/local/lib  gtest/gtest-all.cc gtest/gtest_main.cc -DCPPHTTPLIB_OPENSSL_SUPPORT -I/usr/local/opt/openssl@1.1/include -L/usr/local/opt/openssl@1.1/lib -lssl -lcrypto -DCPPHTTPLIB_ZLIB_SUPPORT -lz -DCPPHTTPLIB_BROTLI_SUPPORT -I/usr/local/opt/brotli/include -L/usr/local/opt/brotli/lib -lbrotlicommon -lbrotlienc -lbrotlidec -pthread
gtest/gtest-all.cc:162:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);
  ^
gtest/gtest-all.cc:183:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);
  ^
gtest/gtest-all.cc:556:28: error: use of undeclared identifier 'FLAGS_gtest_death_test_use_fork'; did you mean '::testing::testing::FLAGS_gtest_death_test_use_fork'?
    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                           ::testing::testing::FLAGS_gtest_death_test_use_fork
/usr/local/include/gtest/internal/gtest-port.h:2181:26: note: expanded from macro 'GTEST_FLAG'
#define GTEST_FLAG(name) FLAGS_gtest_##name
                         ^
<scratch space>:26:1: note: expanded from here
FLAGS_gtest_death_test_use_fork
^
gtest/gtest-all.cc:462:1: note: '::testing::testing::FLAGS_gtest_death_test_use_fork' declared here
GTEST_DECLARE_bool_(death_test_use_fork);
^
/usr/local/include/gtest/internal/gtest-port.h:2232:26: note: expanded from macro 'GTEST_DECLARE_bool_'
  GTEST_API_ extern bool GTEST_FLAG(name); \
                         ^
/usr/local/include/gtest/internal/gtest-port.h:2181:26: note: expanded from macro 'GTEST_FLAG'
#define GTEST_FLAG(name) FLAGS_gtest_##name
                         ^
<scratch space>:16:1: note: expanded from here
FLAGS_gtest_death_test_use_fork
^
gtest/gtest-all.cc:580:5: error: use of undeclared identifier 'FLAGS_gtest_death_test_use_fork'; did you mean '::testing::testing::FLAGS_gtest_death_test_use_fork'?
    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ::testing::testing::FLAGS_gtest_death_test_use_fork
/usr/local/include/gtest/internal/gtest-port.h:2181:26: note: expanded from macro 'GTEST_FLAG'
#define GTEST_FLAG(name) FLAGS_gtest_##name
                         ^
<scratch space>:46:1: note: expanded from here
FLAGS_gtest_death_test_use_fork
^
gtest/gtest-all.cc:462:1: note: '::testing::testing::FLAGS_gtest_death_test_use_fork' declared here
GTEST_DECLARE_bool_(death_test_use_fork);
^
/usr/local/include/gtest/internal/gtest-port.h:2232:26: note: expanded from macro 'GTEST_DECLARE_bool_'
  GTEST_API_ extern bool GTEST_FLAG(name); \
                         ^
/usr/local/include/gtest/internal/gtest-port.h:2181:26: note: expanded from macro 'GTEST_FLAG'
#define GTEST_FLAG(name) FLAGS_gtest_##name
                         ^
<scratch space>:16:1: note: expanded from here
FLAGS_gtest_death_test_use_fork
^
gtest/gtest-all.cc:832:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);
  ^
gtest/gtest-all.cc:854:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);
  ^
gtest/gtest-all.cc:877:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);
  ^
gtest/gtest-all.cc:893:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);
  ^
gtest/gtest-all.cc:1354:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);
  ^
gtest/gtest-all.cc:1445:37: error: no member named 'TestPartResult' in namespace 'testing::testing'
  static const std::vector<testing::TestPartResult>& test_part_results(
                           ~~~~~~~~~^
gtest/gtest-all.cc:1447:12: error: no viable conversion from returned value of type 'const std::vector<TestPartResult>' to function return type 'const int'
    return test_result.test_part_results();
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gtest/gtest-all.cc:1514:5: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);
    ^
gtest/gtest-all.cc:1599:3: error: unknown type name 'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);
  ^
gtest/gtest-all.cc:1521:9: error: no matching constructor for initialization of 'const std::unique_ptr<AbstractSocketWriter>'
      : socket_writer_(new SocketWriter(host, port)) {
        ^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/v1/__memory/unique_ptr.h:118:59: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'testing::internal::StreamingListener::SocketWriter *' to 'const std::unique_ptr<testing::internal::StreamingListener::AbstractSocketWriter>' for 1st argument
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
                                                          ^
/usr/include/c++/v1/__memory/unique_ptr.h:182:21: note: candidate constructor template not viable: no known conversion from 'testing::internal::StreamingListener::SocketWriter *' to 'std::nullptr_t' for 1st argument
  _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {}
                    ^

Version: 0.11.0
googletest-1.12.1 (latest)
clang-14
FreeBSD 13.1

@PixlRainbow
Copy link
Contributor

your compiler appears to be attempting to use your system global installation of gtest, which is a different version from what htttplib uses and includes in its test suite.
Your logs indicate your clang is using gtest/gtest.h from /usr/local/include instead of the one bundled with httplib test folder

@yurivict
Copy link
Author

After the system googletest is removed it fails like this:

test.cc:3:10: error: 'gtest/gtest.h' file not found with <angled> include; use "quotes" instead
#include <gtest/gtest.h>
         ^~~~~~~~~~~~~~~
         "gtest/gtest.h"

clang-14

@PixlRainbow
Copy link
Contributor

add the test directory to the include search path

@yurivict
Copy link
Author

Tests now run, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants