Ask Your Question
1

undefined reference to `vtable for MyViz'

asked 2017-07-06 08:34:52 -0600

mc123 gravatar image

updated 2017-07-06 16:15:22 -0600

In the librviz_tutorial, myviz.h resides in librviz_tutorial/src. I'd like to move it to librviz_tutorial/include/librviz_tutorial. In CMakeLists.txt, I changed include_directories(${catkin_INCLUDE_DIRS}) to include_directories(include ${catkin_INCLUDE_DIRS}), and catkin_package() to catkin_package(INCLUDE_DIRS include). I also changed #include "myviz.h" to #include "librviz_tutorial/myviz.h" in both myviz.cpp and main.cpp However, I get the following error when building:

CMakeFiles/myviz.dir/src/myviz.cpp.o: In function `MyViz::MyViz(QWidget*)':
myviz.cpp:(.text+0x5d): undefined reference to `vtable for MyViz'
myviz.cpp:(.text+0x72): undefined reference to `vtable for MyViz'
CMakeFiles/myviz.dir/src/myviz.cpp.o: In function `MyViz::~MyViz()':
myviz.cpp:(.text+0x98e): undefined reference to `vtable for MyViz'
myviz.cpp:(.text+0x9a0): undefined reference to `vtable for MyViz' 
collect2: error: ld returned 1 exit status
make[2]: *** [/home/user/workspace/devel/.private/librviz_tutorial/lib/librviz_tutorial/myviz] Error 1
make[1]: *** [CMakeFiles/myviz.dir/all] Error 2
make: *** [all] Error 2

I assume this has something to do with inheritance and virtual member functions. Is there anything I can add to CMakeLists.txt to fix this? Or myviz? Thanks.

edit retag flag offensive close merge delete

Comments

It seems like the Qt MOC step may not be executing correctly, but without seeing your full CMakeLists.txt it's impossible to tell.

ahendrix gravatar image ahendrix  ( 2017-07-06 15:11:18 -0600 )edit

As I said in the post, I've only changed two things in the tutorial's CMakeLists.txt:

mc123 gravatar image mc123  ( 2017-07-06 15:36:40 -0600 )edit

I changed include_directories(${catkin_INCLUDE_DIRS}) to include_directories(include ${catkin_INCLUDE_DIRS}), and catkin_package() to catkin_package(INCLUDE_DIRS include)

mc123 gravatar image mc123  ( 2017-07-06 15:37:08 -0600 )edit

You probably need to update https://github.com/ros-visualization/... for the new path to myviz.h .

ahendrix gravatar image ahendrix  ( 2017-07-06 15:58:09 -0600 )edit

Whoops, wrong branch. I'm using kinetic-devel. myviz.h isn't listed in CMakeLists.txt anymore.

mc123 gravatar image mc123  ( 2017-07-06 16:14:56 -0600 )edit

Looks like you're running into this: https://stackoverflow.com/questions/2...

ahendrix gravatar image ahendrix  ( 2017-07-06 21:39:17 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-03-08 13:54:41 -0600

Void gravatar image

I was able to fix this by not having the RViz tutorial headers and sources globbed into the library in the CMakeLists. Basically, have a separate folder for those files.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-07-06 08:34:52 -0600

Seen: 1,345 times

Last updated: Mar 08 '19