问题描述

利用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生成静态库失败问题的更多相关文章

  1. QT中静态库的生成与使用

    一. 静态库的生成    1. 测试目录: lib    2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...

  2. QT中静态库的生成与使用——创建共享库代码,附例子

    一. 静态库的生成    1. 测试目录: lib    2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...

  3. 利用 autoconf 和 automake 生成 Makefile 文件

    一.相关概念的介绍 什么是 Makefile?怎么书写 Makefile?竟然有工具可以自动生成 Makefile?怎么生成啊?开始的时候,我有这么多疑问,所以,必须得先把基本的概念搞个清楚. 1.M ...

  4. 使用CMake编译跨平台静态库

    在开始介绍如何使用CMake编译跨平台的静态库之前,先讲讲我在没有使用CMake之前所趟过的坑.因为很多开源的程序,比如png,都是自带编译脚本的.我们可以使用下列脚本来进行编译:   . / con ...

  5. 手把手教你自动生成Makefile

    概述:autoconf/automake工具用于自动创建功能完善的Makefile文件,接下来简单介绍一下,如何使用上述工具 自动生成Makefile 前提:安装autoconf工具(ubuntu:s ...

  6. Linux静态库生成指南

    Linux静态库生成指南   Linux上的静态库,其实是目标文件的归档文件.在Linux上创建静态库的步骤如下: 写源文件,通过 gcc -c xxx.c 生成目标文件. 用 ar 归档目标文件,生 ...

  7. Linux下Gcc生成和使用静态库和动态库详解(转)

    一.基本概念 1.1什么是库 在windows平台和linux平台下都大量存在着库. 本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行. 由于windows和linux的平台不同( ...

  8. Linux下Gcc生成和使用静态库和动态库详解

    参考文章:http://blog.chinaunix.net/uid-23592843-id-223539.html 一.基本概念 1.1什么是库 在windows平台和linux平台下都大量存在着库 ...

  9. [转]Linux下用gcc/g++生成静态库和动态库(Z)

    Linux下用gcc/g++生成静态库和动态库(Z) 2012-07-24 16:45:10|  分类: linux |  标签:链接库  linux  g++  gcc  |举报|字号 订阅     ...

随机推荐

  1. Spring_总结_04_高级配置(五)_运行时注入值

    一.前言 本文承接上一节:Spring_总结_04_高级配置(四)_bean的作用域 当讨论依赖注入的时候,我们通常所讨论的是将一个bean引用注入到另一个bean的属性或者构造参数中.它通常指的是将 ...

  2. C++结构体成员列表初始化

    C++关于struct和class的区别,可以看上一篇文章:c ++ class和struct[转] 结构体成员列表初始化,来个例子: #include <iostream> #inclu ...

  3. Codeforces Round #266 (Div. 2)B(暴力枚举)

    很简单的暴力枚举,却卡了我那么长时间,可见我的基本功不够扎实. 两个数相乘等于一个数6*n,那么我枚举其中一个乘数就行了,而且枚举到sqrt(6*n)就行了,这个是暴力法解题中很常用的性质. 这道题找 ...

  4. Win 7升级记

    微软要抛弃它的XP了,我也应该提前把家里的PC升级成Win7,省得将来麻烦事多. 其实升级它也很简单,这全要归功于网络上的能人.我首先在网络上下载好一个操作系统DEEP_Ghost_Win7_Sp1_ ...

  5. CodeForces - 688C:NP-Hard Problem (二分图&带权并查集)

    Recently, Pari and Arya did some research about NP-Hard problems and they found the minimum vertex c ...

  6. bae3.0第四步 第一个polls系统

    1.创建自己的app 进入新建的blog工程目录,执行其下面的manage.py来创建polls应用,命令为: python manage.py startapp polls2.定义app的model ...

  7. 用反射封装HttpHandler,实现通过action方法名调用方法

    using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...

  8. 【转】 Pro Android学习笔记(八二):了解Package(1):包和进程

    文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处:http://blog.csdn.net/flowingflying/ 在之前,我们已经学习了如何签发apk,见P ...

  9. [转]RabbitMQ三种Exchange模式(fanout,direct,topic)的性能比较

    RabbitMQ中,所有生产者提交的消息都由Exchange来接受,然后Exchange按照特定的策略转发到Queue进行存储 RabbitMQ提供了四种Exchange:fanout,direct, ...

  10. jdbcTemplate学习(一)

    概述 Spring JDBC抽象框架core包提供了JDBC模板类,其中JdbcTemplate是core包的核心类,所以其他模板类都是基于它封装完成的,JDBC模板类是第一种工作模式. JdbcTe ...