cmake利用toolchain.cmake生成makefile之后,make生成静态库失败问题
问题描述
利用toolchian.cmake设置好编译器后,利用make指令生成静态库,出现以下问题
Error running link command: No such file or directory
出错原因,toolchain.cmake文件内没有声明静态库生成器AR;解决方式,在toolchian.cmake文件内添加下面的声明
SET(CMAKE_AR $(TOOLCHAIN_DIR)/bin/arm-linux-gnueabihf-ar CACHE FILEPATH "Archiver")
我之前的设置是
SET(CMAKE_AR $(TOOLCHAIN_DIR)/bin/arm-linux-gnueabihf-ar)
仍然会报错,在查看了cmake 的文档后发现
Set Normal Variable
set(<variable> <value>... [PARENT_SCOPE])
Set the given <variable> in the current function or directory scope. If the PARENT_SCOPE option is given the variable will be set in the scope above the current scope. Each new directory or function creates a new scope. This command will
set the value of a variable into the parent directory or calling function (whichever is applicable to the case at hand). The previous state of the variable’s value stays
the same in the current scope (e.g., if it was undefined before, it is still undefined and if it had a value, it is still that value).
Cache 变量
Set Cache Entry
set(<variable> <value>... CACHE <type> <docstring> [FORCE])
Set the given cache <variable> (cache entry). Since cache entries are meant to provide user-settable values this does not overwrite existing cache entries by default.
Use the FORCE option to overwrite existing entries. The <type> must be specified as one of: BOOL
Boolean ON/OFF value. cmake-gui() offers a checkbox.
FILEPATH
Path to a file on disk. cmake-gui() offers a file dialog.
PATH
Path to a directory on disk. cmake-gui() offers a file dialog.
STRING
A line of text. cmake-gui() offers a text field or a drop-down selection if the STRINGS cache entry property is set.
INTERNAL
A line of text. cmake-gui() does not show internal entries. They may be used to store variables persistently across runs. Use of this type implies FORCE.
The <docstring> must be specified as a line of text providing a quick summary of the option for presentation to cmake-gui() users. If the cache entry does not exist prior to the call or the FORCE option is given then the cache entry will be set to the given value. Furthermore, any normal variable
binding in the current scope will be removed to expose the newly cached value to any immediately following evaluation. It is possible for the cache entry to exist prior to the call but have no type set if it was created on the cmake() command line by a user through the -D<var>=<value>
option without specifying a type. In this case the set command will add the type. Furthermore, if the <type> is PATH or FILEPATH and the <value> provided on the command
line is a relative path, then the set command will treat the path as relative to the current working directory and convert it to an absolute path.
之后删除build文件下的所有内容
rm -rf *
再次调用cmake生成makefile
cmake -DCMAKE_TOOLCHAIN_FILE=~/toolchain.cmake ../
编译即可
make VERBOSE= -j5
cmake利用toolchain.cmake生成makefile之后,make生成静态库失败问题的更多相关文章
- QT中静态库的生成与使用
一. 静态库的生成 1. 测试目录: lib 2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...
- QT中静态库的生成与使用——创建共享库代码,附例子
一. 静态库的生成 1. 测试目录: lib 2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...
- 利用 autoconf 和 automake 生成 Makefile 文件
一.相关概念的介绍 什么是 Makefile?怎么书写 Makefile?竟然有工具可以自动生成 Makefile?怎么生成啊?开始的时候,我有这么多疑问,所以,必须得先把基本的概念搞个清楚. 1.M ...
- 使用CMake编译跨平台静态库
在开始介绍如何使用CMake编译跨平台的静态库之前,先讲讲我在没有使用CMake之前所趟过的坑.因为很多开源的程序,比如png,都是自带编译脚本的.我们可以使用下列脚本来进行编译: . / con ...
- 手把手教你自动生成Makefile
概述:autoconf/automake工具用于自动创建功能完善的Makefile文件,接下来简单介绍一下,如何使用上述工具 自动生成Makefile 前提:安装autoconf工具(ubuntu:s ...
- Linux静态库生成指南
Linux静态库生成指南 Linux上的静态库,其实是目标文件的归档文件.在Linux上创建静态库的步骤如下: 写源文件,通过 gcc -c xxx.c 生成目标文件. 用 ar 归档目标文件,生 ...
- Linux下Gcc生成和使用静态库和动态库详解(转)
一.基本概念 1.1什么是库 在windows平台和linux平台下都大量存在着库. 本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行. 由于windows和linux的平台不同( ...
- Linux下Gcc生成和使用静态库和动态库详解
参考文章:http://blog.chinaunix.net/uid-23592843-id-223539.html 一.基本概念 1.1什么是库 在windows平台和linux平台下都大量存在着库 ...
- [转]Linux下用gcc/g++生成静态库和动态库(Z)
Linux下用gcc/g++生成静态库和动态库(Z) 2012-07-24 16:45:10| 分类: linux | 标签:链接库 linux g++ gcc |举报|字号 订阅 ...
随机推荐
- Tomcat 多端口访问多应用设置
目的 配置Tomcat,使用多端口访问不同应用 步骤 测试Tomcat版本为apache-tomcat-8.0.5,理论上支持7.0之上的版本 找到tomcat的主目录,打开conf文件夹,找到并打开 ...
- Spring_总结_03_装配Bean(四)_导入与混合配置
一.前言 本文承接上一节:Spring_总结_03_装配Bean(三)之XML配置 在典型的Spring应用中,我们可能会同时使用自动化和显示配置.同时,可能在某些场景下我们需要混合使用JavaCon ...
- 剑指offer--21.链表中倒数第k个结点
定义两个指针,当一个指针指到第K个结点时,第二个指针开始向后移动 -------------- 时间限制:1秒 空间限制:32768K 热度指数:602826 本题知识点: 链表 题目描述 输入一个链 ...
- python的单例模式--解决多线程的单例模式失效
单例模式 单例模式(Singleton Pattern) 是一种常用的软件设计模式,主要目的是确保某一个类只有一个实例存在.希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场 比如,某个 ...
- python_查找模块的方法
在python自带的Command Line中: 1. 查找一个模块拥有的方法 import 模块名 help(模块名) or dir(模块名) 2. 查找一个模块拥有的方法 import 模块名 h ...
- HiHo 1032 最长回文子串 (Manacher算法求解)
/** * 求解最长回文字串,Manacher算法o(n)求解最长回文子串问题 **/ #include<cstdio> #include<cstdlib> #include& ...
- HihoCoder1105 题外话·堆(基础二叉搜索树)
第1行为1个整数N,表示需要处理的事件数目. 接下来的M行,每行描述一个事件,且事件类型由该行的第一个字符表示,如果为'A',表示小Ho将一粒糖果放进了盒子,且接下来为一个整数W,表示这颗糖果的重量: ...
- leetcode_sql_2,183
183. Customers Who Never Order Suppose that a website contains two tables, the Customers table and t ...
- Linux之时间、地点、人物、事件、情节
时间 date 显示当前时间 time cmd 显示 cmd的运行时间 地点 locate 根据文件名,迅速找到文件.基于系统构建的索引 find 根据各种规则找到文件,更强大,但比较慢 wherei ...
- QString 乱谈(1)
一个月前尝试写了一篇关于QStringLiteral,存盘时MoinMoin罢工了.吸取一点经验,还是写成短篇吧 可是,可是,QString不就是简简单单一个字符串么?能有什么可谈的.真的么... ( ...