[Allmake]--cross-compiling is simple

Source: Internet
Author: User
Tags install homebrew

Original articles, reproduced please specify the source: http://www.cnblogs.com/johnd/p/5060530.html

Objective:

Do the embedded development of the siege Lion friends, perhaps you want to do an application, perhaps you want to do the driver, perhaps you want to transplant third-party libraries or applications, cross-compiling is indispensable such as. If you are a rookie, never write Makefile, just here to introduce a development tool to solve your headache problem; If you are a big coffee, it is also your right-hand man, let you focus on the business you want to do, do not have to write lengthy makefile, it is allmake.

Allmake is a cross-platform development tool that is built on make and is very easy to use. You do not need to write Makefile,allmake will work for you, you only need to put your source code into the generated SRC directory, support c/c++/asm hybrid compilation, you do not need to do additional settings, just set your dependencies on the line.

Allmake The biggest feature is easy to use, cross-platform, the same set of C + + code using the same set of configuration, the different compilers placed toolchain below.

Allmake is also very convenient to compile third-party code, usually we say the porting, many articles voluminous thousands of words of the tutorial, Allmake only need simple three lines of command.

Installation Environment:

Windows: Need to install Cygwin or minsys, I install MINSYS2 environment, install gcc or download I686-w64-mingw32 extract to Allmake/toolchain below.

Linux: Any Linux distribution, I'm using Ubuntu 14.04.

MAC: Install homebrew Now, then install gcc,brew install GCC make automake on the command line autoconf

Installation Method :

git clone https://github.com/allmake/allmake.gitcd allmakesudo ./bin/ Allmake-i

start using :

  Follow the above steps to restart your computer and then you can develop a C + + project in any directory, for example, in Ubuntu, create your working directory under $home ~/workspace.

* First we'll look at how to create a project from the zero-C + +

mkdir -P~/workspace/~/workspace/demoallmake Add plat=x86_64-linux (only once, After adding the platform-related configuration, just run the following line of commands. Allmake Clean all release bin

Where add means add configuration, plat represents the abbreviation for platform platform, X86_64-linux is Ubuntu platformx86_64-linux-gnu的名称关键字。你查看安装目录allmake/toolchain/下面有一个目录叫x86_64-linux-gnu,代表我们要寻找的编译器是x86_64-linux-gnu-gcc,如果里面是个空目录,那allmake会使用系统不带前缀的gcc作为编译器,allmake后带了install选项后,所生成的输出文件如头文件、共享库或者可执行二进制文件会安装到allmake/platform/arm-brcm-linux-gnueabi下面,以后你在使用这个库的时候,直接引用头文件就是这样的格式:#include <projectname/headerfile.h>, 以引用demo下面的version.h为例就是 #include <demo/version.h>,而链接依赖就是在添加你的平台时候加入相关选项就是了,如 allmake add plat=x86 COMMON_LIBS=‘-ldemo‘, 表示这个项目要依赖libdemo.so 

If you change the plat=x86_64-linux to PLAT=BRCM, it will be configured asarm-brcm-linux-gnueabi的平台,brcm是编译器arm-brcm-linux-gnueabi的一个关键字。

Well, it's that simple, run the above two lines Allmake command line, you can generate binary executable, let's run it.

./build/x86_64-linux-gnu/obj/demo

Screen output:  

  demo V1.0.0.151212


你可以用 allmake -h 查看使用方法和各个选项的含义,如option有bin表示输出目标格式是个可执行的二进制文件,否则为共享库;install表示allmake会安装输出目标到allmake安装目录中的platform目录下面。

* 跨平台编译第三方源代码
  
一般来说,第三方库都写好了makefile或者configure,allmake做的就是基于现有做好的配置来做更简单的配置,以方便跨平台的移植工作。

  我们使用得最多的就是为arm linux平台移植的时候,下面以编译器
arm-brcm-linux-gnueabi 为例讲解我们经常要用的的一些第三方库的移植方法,使用allmake也是非常的简单,基本上也就三个命令行搞定。
编译第三方库和编译自己的项目使用基本一样的命令,只是配置稍有不同,其中options是指对于使用automake的项目我们一般会这样去配置:

    ./configure --prefix=/usr/local --host=arm-brcm-linux-gnueabi
--enable-feature1 --with-libx

  那你会问,你的allmake没有什么优势啊,看起来都差不多,其实这里面有学问的,你看我们无须值得--host和--prefix,取而代之的是用 plat=编译器的关键字,简单而方便,allmake会自动的寻找你放置在
allmake/toolchain/下的编译器,而这个配置allmake会一直记住的,以后更新代码只需要重新运行 allmake configure和allmake clean all install就可以了,allmake后带了install选项后,所生成的共享库或者可执行二进制文件会安装到allmake/platform/arm-brcm-linux-gnueabi下面。
  而--exports表示要配置指定编译器 CC=
arm-brcm-linux-gnueabi-gcc,AR=arm-brcm-linux-gnueabi-ar,这根据不同的项目要求而定,大部分automake的项目都需要这个配置,只有一些写的比较简单 makefile会有这个要求。
    allmake add plat=the-keyword-of-compiler-folder-name-under-allmake-toolchain options=‘--enable-feature1 --with-libx‘ --exports=‘cc ar‘
    allmake configure
    allmake clean all install
  1. 以移植zlib到arm平台为例,首先添加你要的平台配置,和上面讲的平台配置一样,只需指定关键字就可以了,
Allmake add plat=brcm exports='cc ar' CWD
Allmake Configure
Allmake Clean All Install

   

Summary :

Allmake I through more than 10 years of experience in the use of C + + has been condensed out of some of the essence, it is more important is a programming idea, focus on software modularity, cross-platform, I can easily open a new project, perhaps a separate module, it can be used in different application software, And the application is also very convenient to add this dependency.

Allmake itself is an open source cross-platform development tool with a set of rules to facilitate the establishment and management of your project's tools, you can go to GitHub to download and through the simple help document can achieve a very powerful function, this article first introduced here, if you need, Later I will write a more detailed tutorial.

For more details, please visit Https://github.com/allmake/allmake, if you think allmake is helpful to you, please promote to your friends, so that more people can use it, you can also fork allmake on GitHub.





  

[Allmake]--cross-compiling is simple

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.