Tutorial : how to create a new autotools c project using the buildroot toolchain ?

tpetazzoni edited this page Mar 21, 2013 · 5 revisions

The purpose is to create a new Autotools C project that will use a toolchain generated by Buildroot. With Autotools project, it is up to the developer to write the configure.ac file and the Makefile.am, but it allows the project to be built outside of Eclipse, and to use standard Unix tools as your project build system. For more details about the Autotools, we recommend buying this book, or reading this tutorial.

Create Autotools C project in Eclipse

Create a new C Project: New C Project

Set the project name and select in the GNU Autotools project type the Buildroot toolchain to use to build the project : Select Autotools Buildroot toolchain

Click on Finish.

If you can't find the expected toolchain in the list check that you compiled your Buildroot toolchain with the option Register the Eclipse toolchain activated (see How to activate and install the Buildroot Eclipse plugin ? for details).

When the user selects a toolchain for its project :

  • The PATH environment variable is defined to add the location of the Buildroot toolchain, so that the build process can easily find the cross-compiler and related tools,
  • A default value for the --host configure script option is set, to match the prefix of the cross-compilation toolchain. This will ensure that your project will be correctly cross-compiled with the Buildroot toolchain,
  • The integration with the scanner information was done in order to allow CDT to find automatically the header files,
  • The plugin provides the possibility to create Remote Launch configurations to execute the application on the target,
  • And to create Remote Debug configurations which point automatically on the correct cross-debugger.

Create a new C file : New C file

Create a new configure.ac file : New configure.ac file

Create a new Makefile.am file. Of course, as your project extends, you may create additional Makefile.am files in subdirectories of your project. New Makefile.am file

Invoke the Autoreconf tool. Right-click on the project in the explorer view and select Invoke Autotools->Invoke Autoreconf. This operation will call the autotools to generate the configure script from configure.ac and the Makefile.in from Makefile.am. This operation only has to be done again if you make changes to configure.ac or Makefile.am. Invoke autoreconf

Set the -i option to the autoreconf command, in the opened dialog. This tells autoreconf to automatically install some additional scripts and files that are needed for the correct operation of the configure script. Autoreconf option

We can see in the console that the autoreconf command finished successfully. The configure and Makefile.in files have properly been generated in the project. Autoreconf result

Reconfigure the project. This calls the configure script, passing the --host option that has been set to a default value that ensures that your project will be cross-compiled with the Buildroot toolchain. You may define additional options by changing the properties of your project in Eclipse. Reconfigure project

In the console, we can see that the operation finished succesfully and the Makefile was generated : Reconfigure project result

You can now build the project (Ctrl-b): Build the autotools project