分类目录归档:Ubuntu

Compile HATP planner under Ubuntu 16 | Ubuntu 16 编译 HATP

Recently, my project needs the HATP planner. Compiling under Ubuntu 16 encountered the following problems. Here I wrote down some solutions.

Error: Could not find Antlr

This problem is caused by not installing Antlr2.7.7, so we need compile and install Antlr.

First, download the source package from https://www.antlr2.org/download/antlr-2.7.7.tar.gz

You may meet the following problem during compiling, caused by CharScanner.cpp

make[3]: Entering directory '/home/mydansun/antlr-2.7.7/lib/cpp/src'
*** compiling /home/mydansun/antlr-2.7.7/lib/cpp/src/../../../lib/cpp/src/CharScanner.cpp
In file included from /home/mydansun/antlr-2.7.7/lib/cpp/src/../../../lib/cpp/src/CharScanner.cpp:10:0:
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp:474:30: error: ‘EOF’ was not declared in this scope
  static const int EOF_CHAR = EOF;
                              ^
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp: In member function ‘bool antlr::CharScannerLiteralsLess::operator()(const string&, const string&) const’:
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp:565:41: error: ‘strcasecmp’ was not declared in this scope
   return (strcasecmp(x.c_str(),y.c_str())<0);

The solution is to modify the CharScanner.hpp file manually, add the following code at the beginning.

#include <stdio.h>
#include <strings.h>

The above modification refers to the following two posts

  1. https://stackoverflow.com/questions/4577453/fcgio-cpp50-error-eof-was-not-declared-in-this-scope
  2. https://stackoverflow.com/questions/7248509/strcasecmp-was-not-declared-in-this-scope

After the compilation and installation, when I tried to execute the antlr command, I got this error: Could not find or load main class antlr.Tool

Then I found that there is no antlr.jar file in the /usr/local/lib directory, just copy this file (in the source code directory) to /usr/local/lib.

Important: When compiling HATP later, please use the following command to declare the executable path of Antlr. Otherwise, you may get this error: Unable to find Antlr executable!

catkin_make -DAntlr_BIN=/usr/local/bin/antlr

Error: No rule to make target /usr/lib/libantlr.a

Execute the following command.

sudo ln -s /usr/local/lib/libantlr.a /usr/lib/libantlr.a

Error: toaster_msgs/GetInfoDB.h: No such file or directory

This is because toaster is not installed, please visit the following link

https://github.com/laas/toaster/wiki/Installation

Toaster.git can be cloned into the same workspace as HATP and compile together.

Error: No rule to make target ‘/lib/libtoaster.so’

Execute the following command.

sudo ln -s /usr/local/lib/libtoaster.so /lib/libtoaster.so

最近项目需要HATP规划器,在Ubuntu 16下编译遇到了下面的问题,这里记录一下解决方案。

错误:Could not find Antlr

这个问题是没有安装Antlr2.7.7导致的,我们先编译安装Antlr

首先,下载源码包https://www.antlr2.org/download/antlr-2.7.7.tar.gz

在编译过程中遇到下面的问题,CharScanner.cpp编译失败

make[3]: Entering directory '/home/mydansun/antlr-2.7.7/lib/cpp/src'
*** compiling /home/mydansun/antlr-2.7.7/lib/cpp/src/../../../lib/cpp/src/CharScanner.cpp
In file included from /home/mydansun/antlr-2.7.7/lib/cpp/src/../../../lib/cpp/src/CharScanner.cpp:10:0:
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp:474:30: error: ‘EOF’ was not declared in this scope
  static const int EOF_CHAR = EOF;
                              ^
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp: In member function ‘bool antlr::CharScannerLiteralsLess::operator()(const string&, const string&) const’:
/home/mydansun/antlr-2.7.7/scripts/../lib/cpp/antlr/CharScanner.hpp:565:41: error: ‘strcasecmp’ was not declared in this scope
   return (strcasecmp(x.c_str(),y.c_str())<0);

解决方案就是手动修改CharScanner.hpp 文件,在开头加上下面的代码

#include <stdio.h>
#include <strings.h>

上面的修改参考了下面两篇文章

  1. https://stackoverflow.com/questions/4577453/fcgio-cpp50-error-eof-was-not-declared-in-this-scope
  2. https://stackoverflow.com/questions/7248509/strcasecmp-was-not-declared-in-this-scope

编译安装结束后,尝试执行antlr 命令,却提示Error: Could not find or load main class antlr.Tool

然后发现在/usr/local/lib 目录里没有antlr.jar 文件,将源码目录中的同名文件拷贝到该目录即可。

非常重要:后面编译HATP的时候,请使用下面的命令执行Antlr的可执行文件路径。否则会出现Unable to find Antlr executable!的问题

catkin_make -DAntlr_BIN=/usr/local/bin/antlr

错误:No rule to make target /usr/lib/libantlr.a

执行下面的命令

sudo ln -s /usr/local/lib/libantlr.a /usr/lib/libantlr.a

错误:toaster_msgs/GetInfoDB.h: No such file or directory

这是因为没有安装toaster导致的,参考下面的链接https://github.com/laas/toaster/wiki/Installation

其中toaster.git可以克隆到和HATP相同的workspace,一起编译即可。

错误:No rule to make target ‘/lib/libtoaster.so’

执行下面的命令

sudo ln -s /usr/local/lib/libtoaster.so /lib/libtoaster.so

重装Win10并删除ESP分区后,修复Ubuntu16在UEFI的双系统引导

介绍

最近笔记本的win10一直无法升级到最新版本,查看原因后发现是ESP分区太小了,只有不到100M,而win10推荐的大小是至少500-700M的空间。为了扩大处于分区表开头位置的ESP分区,我删除了ESP以及在ESP之后的win10系统分区。现在硬盘上还存在于Ubuntu的两个分区,一个是挂载点/ ,一个是/home

由于ESP分区直接被删除并且在Win10的重新安装中被彻底重置,原先Ubuntu的EFI启动文件已经被删除。经过多方查找资料。修复的方法如下。

首先,我们用一个Ubuntu的live cd(刻录的U盘也是可以的)启动系统。如果你想先启动你之前的Ubuntu系统内核,请遵循下面的步骤,如果想直接用live cd修复,请直接到修复部分。

启动原Ubuntu内核

在GURB页面按c进去命令行模式,接着输入ls 命令。屏幕中会显示目前所有识别的硬盘以及分区。比如(hd0,gpt1), (ht0,gpt2) 之类的。接下来,使用命令ls (hd0,gpt1)/ 查看这些分区下面的文件夹,找到原先Ubuntu系统/ 挂载点所在的分区。用上面的命令尝试所有的分区(更改命令中的gpt1 为对应的序号),找到含有/boot 文件夹的分区。

找到之后(比如我们确定了是gpt3 ),我们输入set root=(hd0,gpt3)

然后,我们输入set pager=1 来确保分屏显示。

然后,输入cat /boot/grub/grub.cfg 来查看原grub的配置文件。找到第一个menuentry 的启动项。

记录上面以linux 开头这一行的命令,注意可能有折行,要一直抄到尾部,UUID不能错。

然后,稍微上面几行,记录以initrd 开头这一行的命令。

然后,我们依次输入上面记录的两个命令,注意不要出错。最好拍照片拍下来,除了UUID,其他路径部分都是可以用tab补全的。

最后,我们输入boot 命令,启动系统。

修复引导

如果你是使用live cd,请先输入下面的命令进入root用户

sudo -i

然后,我们添加boot-repair 的ppa源并安装,我们需要使用这款软件进行修复。

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair

然后,我们使用sudo boot-repair 命令运行这个工具,然后选择第一个选项。然后按照该工具的提醒进行修复即可。最后这个工具会生成一个报告,可能会花一点时间,耐心等待就好。

显示下面这样的提示证明修复成功,可以重新启动系统进入BIOS调整UEFI的启动顺序为ubuntu即可。

博主在使用boot-repair完成修复后,发现编辑/etc/default/grub 的自定义设置不生效了,并且boot-repair生成的启动菜单项目太多。如果你也遇到上面的问题,你可以在上面的所有操作完成后,进入到你的Ubuntu系统,运行下面的命令重装你的GRUB2

grub-install -v
update-grub

然后再重启系统即可。