Ask Your Question
0

Catkin_make can't find cpp source (add_executable) [Problem found: has to do with WSL file premissions]

asked 2021-02-23 06:56:56 -0500

ThimoF gravatar image

updated 2021-02-23 07:35:59 -0500

I'm sorry if this is not the right forum for this error.

The file structure with CMakeLists and relavant cpp sources:

src/BioSentry/
├── CMakeLists.txt
├── LICENSE
├── README.md
├── include
│   ...
├── launch
│   ...
├── msg
│   ...
├── package.xml
└── src
    ├── image_publisher_node.cpp
    ├── person_detector_node.cpp
    └── rtmp_receiver_node.cpp

Lines from CMakeLists:

add_executable(       ${PROJECT_NAME}_rtmp_receiver_node src/rtmp_receiver_node.cpp)
target_link_libraries(${PROJECT_NAME}_rtmp_receiver_node ${catkin_LIBRARIES} ${OpenCV_LIBS} ${OpenCV_LIBRARIES} )

add_executable(       ${PROJECT_NAME}_image_publisher_node src/image_publisher_node.cpp)
target_link_libraries(${PROJECT_NAME}_image_publisher_node ${catkin_LIBRARIES} ${OpenCV_LIBS} ${OpenCV_LIBRARIES} )

add_executable(       ${PROJECT_NAME}_person_detector_node src/person_detector_node.cpp)
target_link_libraries(${PROJECT_NAME}_person_detector_node ${catkin_LIBRARIES} )

There first two executables have no problems finding the cpp sources in the src folder but the third cannot be found even though it's right next to the others:

thimo@6G-mast:~/catkin_ws$ catkin_make
Base path: /home/thimo/catkin_ws
Source space: /home/thimo/catkin_ws/src
Build space: /home/thimo/catkin_ws/build
Devel space: /home/thimo/catkin_ws/devel
Install space: /home/thimo/catkin_ws/install
####
#### Running command: "cmake /home/thimo/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/thimo/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/thimo/catkin_ws/install -G Unix Makefiles" in "/home/thimo/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/thimo/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/thimo/catkin_ws/devel;/opt/ros/noetic
-- This workspace overlays: /home/thimo/catkin_ws/devel;/opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.5", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/thimo/catkin_ws/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.5")
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.9
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - biosentry_crowd_detection
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'biosentry_crowd_detection'
-- ==> add_subdirectory(BioSentry)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- biosentry_crowd_detection: 1 messages, 0 services
-- Configuring done
CMake Error at BioSentry/CMakeLists.txt:153 (add_executable):
  Cannot find source file:

    src/person_detector_node.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx


CMake Error at BioSentry/CMakeLists.txt:153 (add_executable):
  No SOURCES given to target: biosentry_crowd_detection_person_detector_node


CMake Generate step failed.  Build files cannot be regenerated correctly.
Invoking "cmake" failed
thimo@6G-mast:~/catkin_ws$ ls /home/thimo/catkin_ws/src/BioSentry/src/
image_publisher_node.cpp  person_detector_node.cpp  rtmp_receiver_node.cpp

I'm using Ubuntu 20.04 WSL terminal om Windows 10 with vscode. From the terminal I can see that the changes in the src dir made by vscode are present.

EDIT: Well, I immediately found the problem so I will leave the solution here for the next poor soul: When creating a new file via vscode from my windows host in the WSL filesystem the file does show up with ls but I don't have permission to open it. This is probably why catkin_make can't find it. Connecting to the WSL target using vscode remote ... (more)

edit retag flag offensive close merge delete

Comments

Please post your EDIT as an answer and accept your own answer.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-23 07:20:30 -0500 )edit

And for future questions: please don't post screenshots of terminals/cmd windows. It's all text, so copy-paste it into your question.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-23 07:20:55 -0500 )edit

I fixed the screenshots but I don't have enough points to reopen de question :/

ThimoF gravatar image ThimoF  ( 2021-02-23 07:36:50 -0500 )edit

I've re-opened it.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-23 08:48:37 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-02-23 09:01:57 -0500

ThimoF gravatar image

Well, I immediately found the problem so I will leave the solution here for the next poor soul: When creating a new file via vscode from my windows host in the WSL filesystem the file does show up with ls but I don't have permission to open it. This is probably why catkin_make can't find it. Connecting to the WSL target using vscode remote explorer menu will avoid this in the future!

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: 2021-02-23 06:56:56 -0500

Seen: 136 times

Last updated: Feb 23 '21