博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS7系统上的GPSTK源码安装
阅读量:5892 次
发布时间:2019-06-19

本文共 3910 字,大约阅读时间需要 13 分钟。

网址:http://www.gpstk.org/bin/view/Documentation/BuildingGPSTkUnderUnix

这里使用Cmake来安装源码,网站上的原文摘抄如下,有少部分作了修改的地方,使用红色字体和下划线来标识。

The following procedure will build and install the GPSTk.

  1. Ensure that such as have been installed.
  2. the GPSTk source distribution.
  3. Extract the GPSTk tarball. For example, using GNU tar
    tar xvzf gpstk.tar.gz
  4. Create a directory for your build. For example, change into the gpstk/directory and type
    mkdir build
  5. Change into the gpstk/build directory, this will be where all of the build files will reside.

     

  6. If GPSTk Core will be installed as a system library in /usr/local, execute the following commands:
    cmake ../dev make

     

    To install to a different directory, the install directory must be set-up when CMake configures the makefiles, add the following command:
    -DCMAKE_INSTALL_PREFIX:PATH=/path/to/install

     

    To build GPSTk with Ext, in addition to Core, add the following command:
    -DBUILD_EXT=ON
     
     To turn on processing of python extension package, add the following command: 
    -DBUILD_PYTHON=ON

     

    To turn on test mode, add the following command:
    -DTEST_SWITCH=ON

     

    Example - Command for building GPSTk with core, ext, python, and test code and installing to sytem library in /usr/local:
    [She@she-centos7 gpstk-2.5.src]$ sudo mkdir /opt/gpstk-2.5.linux.x86_64 [She@she-centos7 gpstk-2.5.src]$ cd build[She@she-centos7 build]$ cmake -DBUILD_EXT=ON -DBUILD_PYTHON=ON -DTEST_SWITCH=ON ../dev-- The C compiler identification is GNU 4.8.5-- The CXX compiler identification is GNU 4.8.5-- Check for working C compiler: /usr/bin/cc-- Check for working C compiler: /usr/bin/cc -- works-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working CXX compiler: /usr/bin/c++-- Check for working CXX compiler: /usr/bin/c++ -- works-- Detecting CXX compiler ABI info-- Detecting CXX compiler ABI info - donesystem = Linux-3.10.0-514.16.1.el7.x86_64system_name = LinuxNotice: Will install GPSTk to the path /opt/gpstk-2.5.linux.x86_64-- Configuring done-- Generating doneCMake Warning:  Manually-specified variables were not used by the project:    BUILD_EXT    BUILD_PYTHON-- Build files have been written to: /home/She/Downloads/GPSTK/gpstk-2.5.src/build
     
  7. To install GPSTk, execute
    sudo make install

     

  8. To test GPSTk (if Test_Switch=ON), execute
    sudo make test

     

  9. To build the source documentation using : Change into the gpstk/dev directory (if using Developer repo) or the gpstk/directory (if using the tarball), and type
    doxygen

     

接下来,选择 GPSTK 网站提供的作为测试对象,看程序的功能是否可用。

编译文件 Makefile 内容如下:

PROGRAM    = example RM         = rm -fCC         = g++SOURCES  = example1.cppOBJECTS = ${SOURCES:%.cpp=%.o}LIBPATH += -L/usr/local/libLIBS    =  -lgpstkall:    ${PROGRAM}${PROGRAM}: ${SOURCES} ${OBJECTS}     ${CC} -o ${PROGRAM} ${LIBPATH}  ${OBJECTS} ${LIBS}clean:    ${RM} ${OBJECTS} ${PROGRAM}

编译可以正常通过,但是运行时总是报错,提示

$ make -o example -L/usr/local/lib -lgpstk example1.cpp $ ./exampleerror while loading shared libraries: libgpstk.so: cannot open shared object file: No such file or directory

经查,这个文件/usr/local/lib/libgpstk.so,确实存在,那么,就是默认搜索时找不到这个路径。

为了解决这个bug,我们将这个文件映射到默认搜索路径/usr/lib下:

$ sudo ln -s /usr/local/lib/libgpstk.so /usr/lib/libgpstk.so

 

再重新编译和运行程序,就一切正常了:

$ make clean$ make$ ./exampleHello world!   The current civil time is 06/07/2017 07:16:53 UTC   The current year is 2017   The current day of year is 158   The current second of day is 26213.5   The current full GPS week is 1952   The current short GPS week is 928   The current day of GPS week is 3   The current second of GPS week is 285414   The current Modified Julian Date is 57911.303397479 UTC

 

 如果添加软链接之后仍不奏效,则添加环境变量,使它在运行时能搜索到相应的库文件: $ sudo vi /etc/profile.d/GPSTKsetvar.sh ,添加以下内容:

# setting environment variables for GPSTK, edit by Sheexport LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:/usr/lib

并更新环境变量: source /etc/profile.d/GPSTKsetvar.sh

 

再次编译并运行,即可得到正确的运行结果。

转载于:https://www.cnblogs.com/snake553/p/6955657.html

你可能感兴趣的文章
51Nod 1010 只包含因子2 3 5的数 Label:None
查看>>
Java中String和byte[]间的转换浅析
查看>>
什么是异步
查看>>
WordPress 主题切换
查看>>
cookie和session
查看>>
【java】path和classpath
查看>>
UVa 10057 - A mid-summer night's dream
查看>>
解决3 字节的 UTF-8 序列的字节 3 无效
查看>>
浅谈浏览器兼容性问题-(1)产生、看待与思
查看>>
iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)...
查看>>
BeanUtils\DBUtils
查看>>
VC 创建托盘,托盘tooltip。右键托盘菜单,点击别的地方会隐藏掉的问题。
查看>>
第一天,新的定义
查看>>
WPF EventSetter Handler Command
查看>>
polya定理,环形涂色
查看>>
day4-装饰器前奏
查看>>
【Jest】笔记三:全局变量
查看>>
forward和redirect的区别
查看>>
使用JavaMail完成邮件的编写
查看>>
洛谷P1576 最小花费
查看>>