ubuntu常用库使用-交叉编译

ubuntu常用库使用-交叉编译,第1张

ubuntu常用库使用-交叉编译 Boost
dpkg -S /usr/include/boost/version.hpp
  • 交叉编译
    参考链接
  1. Bootstrap the build system:
./bootstrap.sh
  1. Modify the configuration file (project-config.jam) to use the ARM toolchain by replacing the line with using gcc with:
using gcc : arm : arm-linux-gnueabihf-g++ ;
  1. Build and install the library:
./bjam install toolset=gcc-arm --prefix=/usr/local/boost
  • CMakeLists 中使用
    参考链接
Eigen
  • 查看版本号
    Eigen库版本的定义在/usr/include/eigen3/Eigen/src/Core/util/Macros.h 里面,查看以下字段可以看出使用的版本号为3.3.4。
 #define EIGEN_WORLD_VERSION 3
 #define EIGEN_MAJOR_VERSION 3
 #define EIGEN_MINOR_VERSION 4
  • 交叉编译
  1. 使用cmake-gui进行配置。
    (1)设置源代码目录;设置build目录;点击configure;

    (2)选择交叉编译按钮;

    (3)设置编译器,Target Root一定要选择正确,点击finish;

    search位置输入CMAKE_INSTALL_PREFIX,这里默认为/usr/local,不修改会影响主机上原有库的使用。再次点击configure并generate,完毕后关闭cmake-gui。

  2. build目录下make
    进入build目录下打开终端,输入make开始编译,应该不会报错。

  3. sudo make install
    直接输入sudo make install命令安装,应该不会报错。

  4. 简单示例
    (1)编写test.cpp

#include
#include
using namespace Eigen;
int main()
{
	Matrix2d a;
	a<<5,6,
	       7,8;
	MatrixXd b(2,2);
	b<<1,2,
	       3,4;
	std::cout<<"a+b=n"< 

(2)编译程序

arm-linux-gnueabihf-g++ test.cpp -I /usr/local/include/eigen3 -o test.out

(3)将test.out上传到开发板

scp test.out [email protected]:/userdata

(4)运行程序

./test.out

Eigen交叉编译主要参考了这篇博客链接。

glog

首先在github上下载源代码,然后进行编译;

  • 交叉编译
    glog的交叉编译方法与上文提到的Eigen交叉编译可以使用同样的方法实现,不再赘述;
    此外还参考了另一篇博文,也放在这里作为记录。链接
yaml-cpp

首先在github上下载源代码,然后进行编译;

  • 交叉编译
    yaml-cpp的交叉编译方法与上文提到的Eigen交叉编译可以使用同样的方法实现,不再赘述;

  • 使用示例
    可参考链接。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5699687.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存