Error and Question about CMakeList Unit 2 Example 2.6

I encountered an error with the CMakeList section 2.6 where it asks to use the

add_executable(simple_node src/simple.cpp)

line to create the executable from our cpp file. I followed the instructions verbatim but I kept running into an issue when trying to build it with colcon build where it was not finding the cpp file until I took the src/ out and just ran it as follows:

add_executable(simple_node simple.cpp)

That seemed to work, but my follow-up question is whether this is a bug with the IDE or if when I am building packages on my own, I will need to specify the path to the src folder or if it will automatically check the src folder for the package? I even tried using the absolute path to the file and still got the “cannot find source file” errors, so I just want to know what the proper syntax will be for future projects.

Thanks!

Hi @ianjchadwick ,

Can you share more info:

  • share the cmake file as it is using image from the toolbar.

  • Share the error thats is arising in the webshell when you run the program.

Would be ideal if you share the above after creating a new package. This is because you have made changes to correct the errors from before and i dont want it to influence any new errors.