Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2

colcon build doesn't generate executables

Previous: Answer by GeorgNo for I am trying to get started with ROS2 Humble and when running colcon build no executable files are created.My project structure looks like this:examples ├── CMakeLists.txt ├── package.xml └── src ├── CMakeLists.txt └── helloWorld.cpp File contents:examples/CMakeLists.txt:cmake_minimum_required(VERSION 3.25) project(examples LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) find_package(ament_cmake REQUIRED) add_subdirectory(src) ament_package() examples/src/CMakeLists.txt:add_executable(helloWorld helloWorld.cpp) examples/helloWorld.cpp#include <iostream> using std::cout; using std::endl; int main() { cout << "Hello World" << endl; } Running colcon build in my workspace root succeeds but no executable helloWorld is generated. However, when I edit examples/CMakeLists.txt like this, it DOES work:cmake_minimum_required(VERSION 3.25) project(examples LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) find_package(ament_cmake REQUIRED) #add_subdirectory(src) add_executable(helloWorld "src/helloWorld.cpp") #add executable directly instead ament_package() This successfully generates the executable and works with ros2 run.It looks like add_subdirectory doesn't work correctly... probably has to do something with ament... does anyone know how to do this correctly? I usually strcuture my CMake projects with add_subdirectory and want this to work with ROS as well.
$
0
0
I am trying to get started with ROS2 Humble and when running colcon build no executable files are created. My project structure looks like this: examples ├── CMakeLists.txt ├── package.xml └── src ├── CMakeLists.txt └── helloWorld.cpp File contents: examples/CMakeLists.txt: cmake_minimum_required(VERSION 3.25) project(examples LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) find_package(ament_cmake REQUIRED) add_subdirectory(src) ament_package() examples/src/CMakeLists.txt: add_executable(helloWorld helloWorld.cpp) examples/helloWorld.cpp #include using std::cout; using std::endl; int main() { cout

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images