ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

gtesting a custom class

asked 2012-11-21 05:34:44 -0500

I created the test/myTest.cpp file, which includes the myClass.h header file.

When I compile with make test I get the error ‘MyClass’ does not name a type, where MyClass is the class defined in myClass.h (the error is located where I declare a new MyClass variable)

I think I am missing something with the cmakelists file..

What should I do to compile everything correctly?

I am using ros electric..

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2012-11-21 08:16:04 -0500

Your CMakeList should look something like this:

rosbuild_add_library(myClass_lib src/myClass.cpp)

rosbuild_add_gtest(myTest test/myTest.cpp)

target_link_libraries(myTest myClass_lib)

edit flag offensive delete link more


You are absolutely right... Everything was correct but I forgot to use the right namespace, which caused the error..

Francesco Sacchi gravatar image Francesco Sacchi  ( 2012-11-21 11:34:18 -0500 )edit

Question Tools


Asked: 2012-11-21 05:34:44 -0500

Seen: 126 times

Last updated: Nov 21 '12