gflags的交叉编译

article/2025/10/19 11:09:19

gflags版本:gflags 2.2.2

目录

编译

动态库的编译

  • cmake

设置交叉编译器是重点。

lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ cmake .. -DGFLAGS_NAMESPACE=gflags -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER
=aarch64-linux-gnu-g++
-- The CXX compiler identification is GNU 6.3.1
-- Check for working CXX compiler: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-- Check for working CXX compiler: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -- works
...
-- Configuring done
-- Generating done
CMake Warning:Manually-specified variables were not used by the project:CMAKE_C_COMPILER-- Build files have been written to: /mnt/d/ref/gflags-master/_build
  • make
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ make
Scanning dependencies of target gflags_shared
[ 12%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags.cc.o
[ 25%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_reporting.cc.o
[ 37%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_completions.cc.o
[ 50%] Linking CXX shared library lib/libgflags.so
[ 50%] Built target gflags_shared
Scanning dependencies of target gflags_nothreads_shared
[ 62%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags.cc.o
[ 75%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_reporting.cc.o
[ 87%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_completions.cc.o
[100%] Linking CXX shared library lib/libgflags_nothreads.so
[100%] Built target gflags_nothreads_shared

静态库的编译

  • cmake
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ cmake .. -DGFLAGS_NAMESPACE=gflags -DCMAKE_CXX_FLAGS=-fPIC -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILE
R=aarch64-linux-gnu-g++
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/ref/gflags-master/_build
  • make
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ make
Scanning dependencies of target gflags_static
[ 12%] Building CXX object CMakeFiles/gflags_static.dir/src/gflags.cc.o
[ 25%] Building CXX object CMakeFiles/gflags_static.dir/src/gflags_reporting.cc.o
[ 37%] Building CXX object CMakeFiles/gflags_static.dir/src/gflags_completions.cc.o
[ 50%] Linking CXX static library lib/libgflags.a
[ 50%] Built target gflags_static
Scanning dependencies of target gflags_nothreads_static
[ 62%] Building CXX object CMakeFiles/gflags_nothreads_static.dir/src/gflags.cc.o
[ 75%] Building CXX object CMakeFiles/gflags_nothreads_static.dir/src/gflags_reporting.cc.o
[ 87%] Building CXX object CMakeFiles/gflags_nothreads_static.dir/src/gflags_completions.cc.o
[100%] Linking CXX static library lib/libgflags_nothreads.a
[100%] Built target gflags_nothreads_static

编译结果

安装

将"_build/cmake_install.cmake"文件内的"/usr/local"改为自己交叉编译器所在目录,例如,我的交叉编译器目录为“/usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/"

  • sudo make install
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ sudo make install
[sudo] password for lbw:
[ 50%] Built target gflags_static
[100%] Built target gflags_nothreads_static
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/libgflags.a
-- Installing: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/libgflags_nothreads.a...-- Installing: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/pkgconfig/gflags.pc
-- Installing: /home/lbw/.cmake/packages/gflags/e5f7ce61772240490d3164df06f58ce9
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ sudo make install
[ 50%] Built target gflags_shared
[100%] Built target gflags_nothreads_shared
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/libgflags.so.2.2.2
-- Installing: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/libgflags.so.2.2...-- Up-to-date: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/lib/pkgconfig/gflags.pc
-- Installing: /home/lbw/.cmake/packages/gflags/e5f7ce61772240490d3164df06f58ce9

另一个更方便的方式

  • 更改CMakeLists.txt中的内容

  • 执行  cmake .. && make
lbw@DESKTOP-LBW22:/mnt/d/ref/gflags-master/_build$ cmake .. && make
-- The CXX compiler identification is GNU 6.3.1
-- Check for working CXX compiler: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-- Check for working CXX compiler: /usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done...CMakeFiles/gflags_nothreads_shared.dir/src/gflags_completions.cc.o
[100%] Linking CXX shared library lib/libgflags_nothreads.so
[100%] Built target gflags_nothreads_shared
  • 安装

安装步骤的操作一样(奇怪,CMakeLists.txt中添加的set (CMAKE_INSTALL_PREFIX "/usr/local/ARM-toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/")没起作用)。


http://chatgpt.dhexx.cn/article/Ydvt1FrM.shtml

相关文章

【Ubuntu 20.04】 安装使用 Gflags、Glog、JSON、yaml 教程

Gflags 谷歌命令行解析工具gflags详解 https://zhuanlan.zhihu.com/p/95889124Glog //安装 sudo apt-get install libgoogle-glog-dev //卸载 sudo apt-get remove libgoogle-glog-devGoogle开源库之Glog库详解 https://zhuanlan.zhihu.com/p/26025722JSON Linux C/C下使用…

Ubuntu20.04安装g3log、glog和gflags

建议最好先安装最新版本的cmake,在进行以下安装 cmake安装教程 1.安装gflags 方法一、首先打开终端 ||git clone https://github.com/gflags/gflags.git ||cd gflags ||mkdir build && cd build ||cmake .. -DGFLAGS_NAMESPACEgoogle -DCMAKE_CXX_FLAGS-f…

Gflags learning notes

简介 gflags是谷歌开发的一个命令行标记库,区别于其他命令行标记库,它允许标记定义出现在源文件各处,而不是限定在一个源文件(如main())中。这意味着一个源代码文件定义和使用对该文件有意义的标志,任何链接…

(02)Cartographer源码无死角解析-(09) gflags与glog简介、及其main函数讲解

本人讲解关于slam一系列文章汇总链接:史上最全slam从零开始,针对于本栏目讲解(02)Cartographer源码无死角解析-链接如下: (02)Cartographer源码无死角解析- (00)目录_最新无死角讲解:https://blog.csdn.net/weixin_43013761/article/details/127350885 …

glog和gflags的使用

glog&#xff1a;日志输出 支持debug功能 glog提供特定的宏只在debug模式下生效。以下分别对应LOG、LOG_IF、DLOG_EVERY_N操作的专用宏。 DLOG(INFO) << "Found cookies"; DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; DLO…

【gflags】gflags 命令行参数配置库

gflag介绍 google开源的gflags是一套命令行参数解析工具 主要就是用来解析命令行参数&#xff0c;并且支持从文件或者从环境变量中读入参数&#xff0c;功能十分强大 gflag的使用 我们以使用为目标进行讲解&#xff0c;不会进行深入了解&#xff08;其实并不是很难&#xff0c;…

js判断文件类型详解

js判断文件类型详解 通过file的type属性判断 <input type"file" onchange"onchangecb(this)" /> <script> function onchangecb(e) {const file e.files[0];console.log(file.type); } </script>像html中input标签&#xff0c;就是根…

JS——判断变量类型方法汇总

判断变量类型 一、使用typeof判断变量类型二、使用instanceof判断变量的类型三、使用constructor判断变量的类型四、使用Object.prototype.toString.call判断变量的类型五、使用jquery中$.type判断变量的类型。六、总结 在JS中&#xff0c;有 5 种基本数据类型和 1 种复杂数据类…

JavaScript中的类型判断

js中的类型判断 1、使用typeof进行类型判断2、使用 instanceof 判断对象3、使用Array.isArray()判断数组 1、使用typeof进行类型判断 function fun() { }; console.log("数字的类型为&#xff1a;" typeof (1)); console.log("字符串的类型为&#xff1a;&quo…

js:判断数据类型的几种方法

参考文章&#xff1a;JavaScript中判断对象类型的几种方法总结 根据要判断的数据对象&#xff0c;来选用合适的方法 1、原始数据类型 6种&#xff1a;number、string、boolean、undefined、null、symbol 一、typeof let str hello; console.log(typeof str); // string【特…

JS判断数据类型的几种方式

JS中常见的几种数据类型 基本类型&#xff1a;string、boolean、number特殊类型&#xff1a;undefined和null3、引用类型&#xff1a;Array、Date、RegExp… typeof typeof检测基本数据类型时没有问题&#xff0c;但是当其对引用类型进行检测时&#xff0c;会返回object&…

js 精确判断对象的类型

在 JavaScript 里使用 typeof 来判断数据类型&#xff0c;只能区分基本类型&#xff0c;即 “number”&#xff0c;”string”&#xff0c;”undefined”&#xff0c;”boolean”&#xff0c;”object” 五种。 对于数组、函数、对象来说&#xff0c;其关系错综复杂&#xff0c…

JavaScript——判断js数据类型(类型检测)

判断js数据类型&#xff0c;也就是我们说的类型检测&#xff0c;本文提供五种方法&#xff0c;分别是typeof运算符、instanceof操作符、Object.prototype.toString方法、constructor属性、duck type。 1、typeof运算符 typeof算是最常见的了&#xff0c;使用它会返回一个字符…

js判断数据类型常用的6种方法

js判断数据类型常用的方法,不论在开发中开始在面试中,都是经常遇到的问题,尤其是在面试时,当面试官问及js判断数据类型的方法时,回答的越多,说明掌握的广度跟深度越多,感觉自己逼格也越高.废话不多说了,进入正题 常见的判断js数据类型的方法有如下几种 1.最常见的判断方法&am…

js判断数据类型的几种方法

第一种&#xff1a;Object.prototype.toString()方法&#xff1a; 注意这里是Object原型对象上的toString方法才能判断&#xff0c;其他原型对象上的不能判断&#xff0c;如 Array原型对象上的toString方法是判断不了的&#xff0c;因为它重写了toString方法。 要使用Object…

js判断数据类型(全)

js基本数据类型 基本数据类型&#xff1a; String、Number、Boolean、Undefined未定义、null空、symbol表示独一无二的值&#xff08;es6引入的新的原始数据基本类型&#xff09;。 Number&#xff1a;返回的特殊值NaN&#xff0c;表示不是数值&#xff0c;用于表示本来要返回…

判断JS数据类型的五种方法

JavaScript 中常见的几种数据类型&#xff1a; 目录 JavaScript 中常见的几种数据类型&#xff1a; 一、分类 二、判断 1、typeof null既然属于基本数据类型&#xff0c;为什么用typeof返回的是object呢&#xff1f; js小数运算出现的问题(精度丢失) 解决方法一 解决方…

Linux 文件类型及常用命令(2)(cp、mv、cat、more、less、head、tail、chmod、getenforce)

1、命令 cp&#xff1a;拷贝&#xff08;类似于Windows系统的复制&#xff0c;但区别是可以重命名&#xff09; 拷贝文件、目录&#xff08;需要使用 -r 参数&#xff09;&#xff0c;可以重命名。 2、命令 mv&#xff1a;移动或重命名 ①如果是在当前目录下移动&#xff0c…

Linux验证SELinux状态

安全增强型Linux&#xff08;SELinux&#xff09;是一个Linux内核的功能&#xff0c;它提供支持访问控制的安全政策保护机制。记录操作如何验证SELinux&#xff0c;并且避免系统无法启动的问题。 以root权限执行&#xff1a;sudo su - 运行命令getenforce&#xff0c;验证SELi…

Linux 查看 SELinux 的状态

可以运行下面的命令来查看当前服务配置的 SELinux 的状态。 getenforce 上面的输出状态显示了当前 SELinux 的配置状态。 如果上图显示当前的状态。 临时禁用 SELinux 。 使用下面的命令来临时禁用 SELinux。 setenforce 0 Linux 查看 SELinux 的状态 - 系统和容器 - OSSE…