Ask Your Question
0

how to solve the problem of cannot determine linker language for target?

asked 2015-05-09 04:24:43 -0500

anthuny shin gravatar image

updated 2015-05-10 02:29:48 -0500

gvdhoorn gravatar image

hi:)

when i build the program, found the error like 'cannot determine linker language for link target

below is the my cmakelist.txt's content

find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  OpenCV
)

catkin_python_setup()

include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

add_executable(opencv_test2 script/opencv_test2.py)

target_link_libraries(opencv_test2
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
 )

 install(PROGRAMS
   script/opencv_test2.py
   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )

please, how to solve this problem?

please know where is the problem exactly.


Edit:

i revised my cmakelist.txt

but occur the error that ' cannot speify link libraries for target " scripts/opencv_test1.py" which is not built by this project.

note opencv_test1.py can execute

what is the problem?

i must solve this problem. pleas help me

cmake_minimum_required(VERSION 2.8.3)
project(opencv_test1)

find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
)

find_package(OpenCV REQUIRED)

catkin_package(
  LIBRARIES opencv_test1
  CATKIN_DEPENDS opencv2 rospy std_msgs
  DEPENDS system_lib
)

include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
)

 target_link_libraries(scripts/opencv_test1.py
   ${catkin_LIBRARIES}
   ${OpenCV_LIBRARIES}
 )
edit retag flag offensive close merge delete

Comments

1

Don't use answers to update your question, this is not a forum. Update your original question in the future.

I've moved the contents of your answer to your question.

gvdhoorn gravatar image gvdhoorn  ( 2015-05-10 02:30:39 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-05-09 05:49:26 -0500

gvdhoorn gravatar image

updated 2015-05-10 02:40:55 -0500

Is this your entire CMakeLists.txt? Please provide a complete copy.

If this is the complete contents, you seem to be missing two important statements. A typical CMakeLists.txt starts with:

cmake_minimum_required(VERSION 2.8.3)
project(your_package)

See also wiki/catkin/CMakeLists.txt - Overall Structure and Ordering and catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Catkin configuration overview - CMakeLists.txt

Also:

add_executable(opencv_test2 script/opencv_test2.py)

You can (and should) use a CMakeLists.txt for ROS Python nodes, but you don't use add_executable(..) then. See catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Installing Python scripts and modules for more info on using catkin with Python.

Note that you don't need to install your script / node in order to be able to rosrun or roslaunch it. You only need a minimal CMakeLists.txt to build your package, catkin will do the rest.


Edit:

i revised my cmakelist.txt

but occur the error that ' cannot speify link libraries for target " scripts/opencv_test1.py" which is not built by this project.

Have you read the documentation I linked? You cannot link Python nodes to anything using target_link_libraries(..). That is for C/C++/other compiled languages only. There is nothing to link with Python.

Also: include_directories(..) is useless with Python nodes. The PYTHONPATH is setup by sourcing the correct setup.(bash|sh|zsh) after building your workspace.

A minimal CMakeLists.txt for a Python only package is probably something like:

cmake_minimum_required(VERSION 2.8.3)
project(your_project_name)

find_package(catkin REQUIRED)

# depending on whether you have any libraries to install/export
#catkin_python_setup()

# add relevant arguments here (CATKIN_DEPENDS etc)
catkin_package()
edit flag offensive delete link more

Comments

cmake_minimum_required(VERSION 2.8.3) project(kr120_final)

find_package(catkin REQUIRED)

catkin_package()

install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} PATTERN "setup_assistant.launch" EXCLUDE) install(DIRECTORY config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

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

This is what i have in CMakeList.txt file when i build catkin environment by "catkin_make" command, it does give the same error, 1. i have written node in c++ language,and followed the moveit official documentation.

dharmendra gravatar image dharmendra  ( 2020-05-11 04:28:15 -0500 )edit

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: 2015-05-09 04:24:43 -0500

Seen: 16,080 times

Last updated: May 10 '15