[ros-users] [Discourse.ros.org] [Next Generation ROS] Issues with ament CmakeLists

Arunava Nag ros.discourse at gmail.com
Mon Sep 11 10:26:07 UTC 2017



Hello All,

I just started out with ROS 2.0. I have the latest build. I am unsure if I am doing something stupid or missing out something. However, I can't build these simple files. If I should have posted somewhere else kindly let me know. 
Command used for building:

    ament build --symlink-install --only-package testpackage


Error thrown:
![image|690x240](upload://t9jt2VJ0uiOIvO6bloVaRnVDnwJ.png)

This is my test_node.cpp

    #include <testpackage/testpackage.h>
      int main(int argc, char * argv[]){
	     rclcpp::init(argc, argv);
	     auto node = rclcpp::node::Node::make_shared("test");
	     testRos2 test_object;
	     test_object.initialize(node);
	     rclcpp::spin(node);
	     return 0;
     }


This is my test.cpp

    #include <testpackage/testpackage.h>
     testRos2::testRos2(){    }
     testRos2::~testRos2(){  }
     void testRos2::initialize(std::shared_ptr<rclcpp::node::Node>& n){
     }

This is my header: 
 
    #pragma once
    #ifndef TESTPACKAGE
    #define TESTPACKAGE

    #include <iostream>
    #include <string>

    #include "rclcpp/rclcpp.hpp"
    #include "std_msgs/msg/string.hpp"

    using namespace std;

    class testRos2{

    public:
	  testRos2();
	  ~testRos2();
	  void initialize(std::shared_ptr<rclcpp::node::Node>&);
     };
    #endif


CMakeLists:

    cmake_minimum_required(VERSION 3.5)

    project(testpackage)

    if(NOT WIN32)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
    endif()

    find_package(ament_cmake REQUIRED)
    find_package(rclcpp REQUIRED)
    find_package(std_msgs REQUIRED)

    include_directories(include 
					${rclcpp_INCLUDE_DIRS}
                    ${rmw_implementation_INCLUDE_DIRS}
                    ${std_msgs_INCLUDE_DIRS})

    add_library(test_lib
      src/test.cpp
     )
    target_link_libraries(test_lib ${rclcpp_LIBRARIES} ${rmw_implementation_LIBRARIES} ${std_msgs})

    add_executable(test_node src/test_node.cpp)
    ament_target_dependencies(test_node test_lib rclcpp std_msgs)

    install(
      DIRECTORY include/${PROJECT_NAME}/
      DESTINATION include
    )

    install(
      TARGETS test_lib test_node 
      ARCHIVE DESTINATION lib
     LIBRARY DESTINATION lib
     RUNTIME DESTINATION bin
    )

    ament_package()





---
[Visit Topic](https://discourse.ros.org/t/issues-with-ament-cmakelists/2608/1) or reply to this email to respond.




More information about the ros-users mailing list