자택경비대

'c++'에 해당되는 글 1건

  1. google test 컴파일 에러 해결법

google test 컴파일 에러 해결법

Programming

google test는 C++ 단위 테스트 환경 구축을 위한 프레임워크이다.

In file included from sample.cpp:1:
In file included from /usr/local/include/gtest/gtest.h:62:
In file included from /usr/local/include/gtest/internal/gtest-internal.h:40:
/usr/local/include/gtest/internal/gtest-port.h:826:12: error: no member named
      'make_tuple' in namespace 'std'
using std::make_tuple;
      ~~~~~^
/usr/local/include/gtest/internal/gtest-port.h:827:12: error: no member named 'tuple' in
      namespace 'std'
using std::tuple;
      ~~~~~^
/usr/local/include/gtest/internal/gtest-port.h:906:3: warning: deleted function
      definitions are a C++11 extension [-Wc++11-extensions]
  GTEST_DISALLOW_ASSIGN_(RE);
  ^
/usr/local/include/gtest/internal/gtest-port.h:672:34: note: expanded from macro
      'GTEST_DISALLOW_ASSIGN_'
  void operator=(type const &) = delete
                                 ^
/usr/local/include/gtest/internal/gtest-port.h:949:3: warning: deleted function
      definitions are a C++11 extension [-Wc++11-extensions]
  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
  ^
/usr/local/include/gtest/internal/gtest-port.h:677:24: note: expanded from macro
      'GTEST_DISALLOW_COPY_AND_ASSIGN_'
  type(type const &) = delete; \
...

위의 에러는 google test를 포함한 테스트 코드가 -std=c++11 혹은 이상의 플래그를 포함하지 않아서 발생하는 문제이다.

Makefile의 경우에는 CXXFLAGS=-std=c++11을 추가해주면 해결된다.


+추가내용)

Undefined symbols for architecture x86_64:
"testing::Test::SetUp()", referenced from:
...

위의 경우에는 라이브러리가 연결되지 않아서 발생하는 문제이다.

마찬가지로 Makefile에서는 LDLIBS=-lgtest_main -lgtest -pthread 플래그를 추가하여 해결 할 수 있다.