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 |举报|字号 订阅 ...
随机推荐
- nginx Win下实现简单的负载均衡(1)nginx搭建部署
快速目录: 一.nginx Win下实现简单的负载均衡(1)nginx搭建部署 二.nginx Win下实现简单的负载均衡(2)站点共享Session 三.nginx Win下实现简单的负载均衡(3) ...
- CentOS 6.8安装Docker V1.0
rpm -Uvh http://dl.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum -y install do ...
- XXX.APP已损坏,打不开.你应该将它移到废纸篓
XXX.APP已损坏,打不开.你应该将它移到废纸篓 MACOS 10.12 SIERRA 如遇:「xxx.app已损坏,打不开.你应该将它移到废纸篓」,并非你安装的软件已损坏,而是Mac系统的安全设置 ...
- react-webpack(一)
要让webpack知道这就是我们的index.html入口文件,并且我们不需要手动引入打包后的js文件,需要安装html-webpack-plugin npm install html-webpack ...
- BEC listen and translation exercise 6
能听懂自己的录音,说明发音还行,可惜听不懂... Another problem is that the members of the Biramichi fishing cooperative ar ...
- UVA - 11019 Matrix Matcher (二维字符串哈希)
给你一个n*m的矩阵,和一个x*y的模式矩阵,求模式矩阵在原矩阵中的出现次数. 看上去是kmp在二维情况下的版本,但单纯的kmp已经无法做到了,所以考虑字符串哈希. 类比一维情况下的哈希算法,利用容斥 ...
- numpy、scipy、pandas
以下分别是numpy.Scipy.pandas的简介.虽然这些包提供的一些结构比python自身的“更高级.更高效”,更高级是因为它们能完成更高级的任务,但是,学习的时候尽量不要和python割裂开认 ...
- ADMEMS软件架构的4个阶段
业界软件架构设计的方法论很多,各有各自的应用场景和特点,下文结合ADMEMS(Architecture Design Method has been Extended to Method System ...
- Python修复图像文件后缀名
网上爬了很多图片,有很多错误. 有的不是图片文件,需要删除 有的后缀名错误,需要更正 用的的python脚本 #!/usr/bin/env python #-*- coding: utf-8 -*-# ...
- 记录启用HTTPS的全过程
因为 https 采用 ssl 加密,所以部署 https 时需要申请证书,证书的作用就是对浏览器和Web服务器双方的身份验证. 步骤1:申请证书 我们采用Let's Encrypt签发的免费证书,虽 ...