ROS中V-REP安装和编译的问题解决

首先要使用V-REP,就要下载下来,我的系统是ubuntu18.04.

下载命令$;wget http://copperliarobotics.com/files/V-REP_PRO_EDU_V3_4_0_linux.tar.gz

下载完成后,提取存档

命令$:tar -zxvf V-REP_PRO_EDU_V3_4_0_linux.tar.gz

在这里下载可能会遇到下载很慢的问题,可能使用默认的源下载会比较慢,可以选择进行换源,我这里换的是

阿里的源,方法如下:

进入源文件$:vim /etc/apt/sources.list

阿里的源

1 deb http://mirrors.aliyun.com/ubuntu/ bionic main r   estricted universe multiverse                      
 2 deb-src http://mirrors.aliyun.com/ubuntu/ bionic ma   in restricted universe multiverse
 3 
 4 deb http://mirrors.aliyun.com/ubuntu/ bionic-securi   ty main restricted universe multiverse
 5 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-se   curity main restricted universe multiverse
 6 
 7 deb http://mirrors.aliyun.com/ubuntu/ bionic-update   s main restricted universe multiverse
 8 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-up   dates main restricted universe multiverse
 9 
10 deb http://mirrors.aliyun.com/ubuntu/ bionic-propos   ed main restricted universe multiverse
11 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-pr   oposed main restricted universe multiverse
12 
13 deb http://mirrors.aliyun.com/ubuntu/ bionic-backpo   rts main restricted universe multiverse
14 deb-src http://mirrors.aliyun.com/ubuntu/ bionic-ba   ckports main restricted universe multiverse

 将上面的源替换源文件里面的默认源

然后在更新一下$:sudo apt-get update  ,就可以了。

接下来我们要给提取出来的文件改一个名字,方便定义环境变量

命令$:mv V-REP_PRO_EDU_V3_4_0_Linux v-rep

为了方便访问V-REP资源,可以设置一个环境变量(VREP_RPPT)指向V-REP的主文件

命令$:echo "export VREP_ROOT = ~/home/qqtsj/v-rep >> ~/.bashrc"   这里需要选择你自己对应的文件路径。

下载两个软件包到工作空间就可以编译了

git clone https://github.com/jocacace/vrep_common.git
git clone https://github.com/jocacace/vrep_plugin.git

 在工作空间使用catkin_make进行编译

快编译成功时却出现以下错误

[100%] Linking CXX shared library /home/qqtsj/catkin_ws/devel/lib/libv_repExtRos.so
/usr/bin/ld: 找不到 -lroslib
/usr/bin/ld: 找不到 -lrosconsole
/usr/bin/ld: 找不到 -lrostime
/usr/bin/ld: 找不到 -lrospack
/usr/bin/ld: 找不到 -lroscpp_serialization
/usr/bin/ld: 找不到 -lroscpp
/usr/bin/ld: 找不到 -ltf
/usr/bin/ld: 找不到 -limage_transport
collect2: error: ld returned 1 exit status
vrep_plugin/CMakeFiles/v_repExtRos.dir/build.make:297: recipe for target '/home/qqtsj/catkin_ws/devel/lib/libv_repExtRos.so' failed
make[2]: *** [/home/qqtsj/catkin_ws/devel/lib/libv_repExtRos.so] Error 1
CMakeFiles/Makefile2:13873: recipe for target 'vrep_plugin/CMakeFiles/v_repExtRos.dir/all' failed
make[1]: *** [vrep_plugin/CMakeFiles/v_repExtRos.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

 经过查阅资料,原因是是因为库没有链接好。

解决方案如下:

例如第一条$:/usr/bin/ld: 找不到 -lroslib

确定该文件的所在目录

命令$:locate libroslib   得到如下:

/opt/ros/melodic/lib/libroslib.so

 然后链接库,输入命令;

sudo ln -s /opt/ros/melodic/lib/libroslib.so /usr/lib/libroslib.so

 下面的库连接的以此类推

就可以解决了。

原文地址:https://www.cnblogs.com/tanshengjiang/p/13261852.html