CMake Error: add_executable cannot create target ““ because another target with the same name已解決

宇宙爆肝錦標賽冠軍發表於2020-12-31


catkin_make報錯輸出如下:

CMake Error at experiment3/CMakeLists.txt:215 (add_executable):
  add_executable cannot create target "track" because another target with the
  same name already exists.  The existing target is an executable created in
  source directory "/home/zth/work_ws/src/experiment3".  See documentation
  for policy CMP0002 for more details.

解決方法:

CMakeLists.txt部分內容如下:
在這裡插入圖片描述
這裡有兩處忘記改了,改為如下內容即可:

add_executable(receive_process src/receive_process.cpp)
target_link_libraries(receive_process ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

add_executable(show_img src/show_img.cpp)
target_link_libraries(show_img ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

相關文章