标签归档:Ubuntu 16

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