Record problems and solutions when creating OpenCV and ROS workspaces

1 Variable 'exec_prefix' not defined in '/usr/local/lib/pkgconfig/opencv.pc'

After a detailed search on the Internet, the configuration information file opencv.pc is missing or there is a problem with the content in the file, so the solution is to add this file and import it into the environment variable

1.1 Create opencv.pc file

sudo touch opencv.pc

Because you do not have permission to modify, first modify the permissions of the file

Change file permissions

Enter the terminal in the same directory:

sudo chmod 777 opencv.pc

Copy the following content to opencv.pc

prefix=/usr/local

exec_prefix=${prefix}

includedir=${prefix}/include

libdir=${exec_prefix}/lib

Name: opencv

Description: The opencv library

Version:4.1.1

#This 4.1.1 is the OpenCV version and needs to be changed to your own version

Cflags: -I${includedir}/opencv4

Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core

~

1.2 Save and exit, and then import the file to the environment variable: (Enter the environment variable method: gedit ~/.bashrc)

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Then look at the source:

source ~/.bashrc

Finally, enter the following to see the version of OpenCV

pkg-config --modversion opencv

2 Problems encountered when recording catkin_make

at /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):

Could not find a package configuration file provided by "OpenCV" with any

of the following names:

OpenCVConfig.cmake

opencv-config.cmake

Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set

"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"

provides a separate development package or SDK, be sure it has been

installed.

Invoking "make cmake_check_build_system" failed

Solution:

Problems encountered when recording catkin_make

E: Unable to locate package ros-kinetic-driver-base

Problems encountered in downloading controls, to install your own version controls:

My system is Ubuntu20.04 and noteic version control needs to be installed:

sudo apt-get install ros-noetic-driver-base

sudo apt-get install ros-noetic-gazebo-ros-control

sudo apt-get install ros-noetic-effort-controllers

sudo apt-get install ros-noetic-joint-state-controller

sudo apt-get install ros-noetic-ackermann-msgs

sudo apt-get install ros-noetic-global-planner

sudo apt-get install ros-noetic-teb-local-planner

3 记录catkin_make时遇到的问题

Invoking "cmake" failed

解决方法:

pip install -U rosdep rosinstall_generator wstool rosinstall six vcstools -i https://pypi.douban.com/simple

或catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

参考文章链接:https://blog.csdn.net/qq_44920947/article/details/123300367

没有成功尝试别的方法:

本文链接:https://blog.csdn.net/qq_39437730/article/details/118272390

没有解决换一个方法:

总结了常见问题

ubuntu 20.04 安装 ROS noetic,catkin_make报错python版本不一致,处理办法

catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3

cmake找不到opencv解决

本文链接:https://blog.csdn.net/jacke121/article/details/112827563

source ~/catkin_ws/devel/setup.bash

· 1

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/catkin_ws/

自建引用包报错:CMake Error at /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):

解决方法:

1.将opencv安装目录添加到CMAKE_PREFIX_PATH

例如,按照错误信息指示,在CMakeLists.txt中加入一行list,路径要改成自己的opencv安装路径。

list(APPEND CMAKE_PREFIX_PATH "/home/xiaoming/opencv4.5.5/")

find_package(OpenCV REQUIRED)

4 运行catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3时

出现:The specified source space "/home/sxj/src" does not exist

回到catkin_ws工作空间下进行编译

或者可能曾经误在home下catkin init过,系统误认为home是工作空间

home下ctrl+h显示隐藏文件

删除文件夹.catkin_tools

参考链接:https://blog.csdn.net/Cwenge/article/details/90545262

Guess you like

Origin blog.csdn.net/m0_60657960/article/details/129724835