1

I installed Jenkins on a CentOS vm. Now I want to run unittests (google test) with mocks (google mock). I tried installing the frameworks like described here. (On my lubuntu machine everything runs without a problem using these steps)

When I try to build:

g++ -O2 -pthread -Werror -Wall -o unitTest DriveTest.cpp Drive.cpp PWM.cpp -lgtest -lgtest_main -lgmock

I get the following errors:

 make unitTest
 g++ -O2 -std=c++0x -pthread -Werror -Wall -o unitTest DriveTest.cpp Drive.cpp PWM.cpp -lgtest -lgtest_main -lgmock
 In file included from /usr/include/gmock/gmock-spec-builders.h:75,
                  from /usr/include/gmock/gmock-generated-function-mockers.h:43,
                  from /usr/include/gmock/gmock.h:61,
                  from PWMMock.h:4,
                  from DriveTest.cpp:1:
 /usr/include/gmock/gmock-matchers.h:1485: sorry, unimplemented: cannot expand ‘Tail ...’ into a fixed-length argument list
 /usr/include/gmock/gmock-matchers.h:1486: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1486: error: ‘ListType’ in class ‘int’ does not name a type
 /usr/include/gmock/gmock-matchers.h:1486: error: template argument 2 is invalid
 /usr/include/gmock/gmock-matchers.h:1486: error: expected ‘::’ before ‘ListType’
 /usr/include/gmock/gmock-matchers.h: In static member function ‘static int testing::internal::MatcherList<kSize, Head,
 Tail>::BuildList(const Head&, const Tail& ...)’:
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘BuildList’ is not a member of ‘int’
 /usr/include/gmock/gmock-matchers.h: In static member function ‘static testing::Matcher<T> testing::internal::MatcherList<kSize,
 Head, Tail>::CreateMatcher(const int&)’:
 /usr/include/gmock/gmock-matchers.h:1503: error: request for member ‘first’ in ‘matchers’, which is of non-class type ‘const int’
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘CreateMatcher’ is not a member of ‘int’
 ...

How can I fix this?

Community
  • 1
  • 1
RIPS10
  • 28
  • 6

1 Answers1

1

It seems as though the version of GCC you have on CentOS is too old to handle these variadic templates. I would expect 4.4.7 to have them available since the status page seems to indicate they should. However this question seems to confirm the situation.

My advice would be to upgrade the compiler using the dev-toolset 2 repo. This will give you access to GCC 4.8 on CentOS 6 (which by the GCC version is what I'm guessing you're using) but with a modified stdlib which means your binaries will still run using the runtime from CentOS/RedHat 5.

sjdowling
  • 2,994
  • 2
  • 21
  • 31
  • I upgraded gcc with dev-toolset 2. g++ -v now shows: gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC) I can now build my project in CentOS without a problem. But Jenkins still shows the same errors? – RIPS10 Jun 03 '15 at 07:38
  • @RIPS10 Is Jenkins using gcc 4.8 or the old 4.4? You might need to put a `source /opt/rh/devtoolset-2/enable` line at the top of your Jenkins build script to ensure the environment is switched to use the new toolchain. – sjdowling Jun 03 '15 at 08:12
  • Thanks, Jenkins was somehow still using the old compiler. The extra line solved my problem. – RIPS10 Jun 03 '15 at 12:12