Ask Your Question
0

Undefined reference to shapes::createMeshFromResources()

asked 2020-06-15 18:22:08 -0500

On Ubuntu 16.04, with ROS kinetic, I am getting a link error, "undefined reference to shapes::createMeshFromResource()"

The code looks like this:

#include "ros/ros.h"
#include "geometric_shapes/shapes.h"
#include "geometric_shapes/mesh_operations.h"
#include <string>
#include <stdio.h>

int main(int argc, char** argv)
{
    // Read an stl file into a mesh shape
    const std::string filename("./testMesh.stl");
    Eigen::Vector3d vectorScale(0.001, 0.001, 0.001);
    shapes::Mesh* mesh = shapes::createMeshFromResource(filename, vectorScale);

    return 0;
}

CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.0.2)
project(stereocam_pkg)

add_compile_options(-ggdb -std=c++11 -I. -I/usr/include/eigen3 ${Eigen_INCLUDE_DIRS})

find_package(catkin REQUIRED COMPONENTS
  message_generation
  message_runtime
  roscpp
  std_msgs
  Eigen3
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Eigen_INCLUDE_DIRS}
)

add_executable(meshLoader src/meshLoader.cpp)
target_link_libraries(meshLoader ${catkin_LIBRARIES} ${Eigen3_LIBRARIES} ${Boost_LIBRARIES})

I get the following link error from catkin_make:

...
-- +++ processing catkin package: 'stereocam_pkg'
-- ==> add_subdirectory(stereocam_pkg)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sysadmin/cws/SeaSnail/catkin_ws/build
####
#### Running command: "make -j8 -l8" in "/home/sysadmin/cws/SeaSnail/catkin_ws/build"
####
[ 50%] Linking CXX executable meshLoader
CMakeFiles/meshLoader.dir/src/meshLoader.cpp.o: In function `main':
/home/.../catkin_ws/src/stereocam_pkg/src/meshLoader.cpp:21: undefined reference to `shapes::createMeshFromResource(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&)'
collect2: error: ld returned 1 exit status
stereocam_pkg/CMakeFiles/meshLoader.dir/build.make:102: recipe for target 'stereocam_pkg/meshLoader' failed
make[2]: *** [stereocam_pkg/meshLoader] Error 1
CMakeFiles/Makefile2:399: recipe for target 'stereocam_pkg/CMakeFiles/meshLoader.dir/all' failed
make[1]: *** [stereocam_pkg/CMakeFiles/meshLoader.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
$

Any help figuring this out would be much appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-06-16 02:37:13 -0500

gvdhoorn gravatar image

updated 2020-06-16 02:42:28 -0500

find_package(catkin REQUIRED COMPONENTS
  message_generation
  message_runtime
  roscpp
  std_msgs
  Eigen3
)

You appear to be missing geometric_shapes in this list. That's most likely the problem: you're not linking against geometric_shapes, but are using a function from that library.

And unless this is an excerpt, you don't appear to need message_generation nor message_runtime here.

Also (but off-topic):

add_compile_options(-ggdb -std=c++11 -I. -I/usr/include/eigen3 ${Eigen_INCLUDE_DIRS})

The -I., -std=c++11 and -I/usr/include/eigen3 ${Eigen_INCLUDE_DIRS} seem unnecessary, and should be using CMake functionality instead.

Especially -I.: did you really need this?

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: 2020-06-15 18:22:08 -0500

Seen: 17 times

Last updated: Jun 16