4.2.1. Eclipse Managed Build
To begin with, this can be the simplest way to build a new Project.(But it only works with GCC and other Eclipse supported tool-chains.) [1]
CDT gives a GUI to:
- Manage the build
- Selectively exclude/include some files from build.
- Maintain build configurations
- Indexing works out-of-the-box
With Eclipse managed build, Eclipse can automatically create a set of makefiles. These makefiles can be used with standard make utility. Thus, if the project ismanaged within Eclipse, developers not using Eclipse can still build thesoftware. It is also useful for automated standalone builds.
Note
Older versions of CDT used to refer this as a Managed make project
4.2.1.1. Creating a sample project
Click File ? New ? Project
Select C Project
Name the project as Hello World.
Select project type as Hello World ANSI C Project
Select Tool-chain as MinGW GCC
Click Next button
Input your details
Click Next button
Select Advanced settings
Select Current builder as Gnu Make Builder
Click OK button
Click Finish button
If you get a message to switch perspective, Click Yes
This happens if the previous perspective was not C/C++ perspective.
This is how the Project Explorer view would look like.
- The name of the project HelloWorld
- Eclipse would list executables and libraries of the project here.
- Eclipse would list include directories and header files here.
- Eclipse generated folder. The name is derived from the buildconfiguration.
- Eclipse generated Makefiles
- The actual source file.
To build the project, do either of:
Press Ctrl + B
Click Project ? Build All
Press the Build Button
4.2.1.2. Build Configuration
Build configurations are different ways of building a code. The most basicwould be Debug mode and Retail Mode. In Debug mode, the generated objectsand executables have Debug symbols. For large projects, this can becomefurther complicated. Including files for test code, excluding files for testcode, etc.
Each configuration can have unique set of source files, includes, #defines,and other compiler/linker parameters.
4.2.1.3. Changing Build Settings
Eclipse gives control over how the project gets build.
4.2.1.3.1. Include / Exclude Files from Build
Use Right Click ? Resource Configuration ? Exclude FromBuild to add/remove a source file from a Build Configuration
Even finer control can be achieved through, Project ?Properties ? C/C++ General ? Paths and Symbols ? Source Location (SeeIncluding / Excluding files & directories from build)
![](http://pubimage.360doc.com/wz/default.gif)
Including / Excluding files & directories from build
4.2.1.3.2. Compiler Directives
Through Project ? Properties ? C/C++ General ? Pathsand Symbols ? Includes we can Add include paths to build.
![](http://pubimage.360doc.com/wz/default.gif)
Add include paths to build
Through Project ? Properties ? C/C++ General ? Pathsand Symbols ? Symbols we can Add compiler defines to build.
![](http://pubimage.360doc.com/wz/default.gif)
Add compiler defines to build
4.2.1.3.3. Change the Make Utility
To Change the default build utility, from make to somethingelse, go to Project ? Properties ? C/C++ Build ?Builder Settings
![](http://pubimage.360doc.com/wz/default.gif)
Change the default build utility
To change Advanced build settings , e.g. using Paralleljobs for build (-j), or build on every save, go to Project? Properties ? C/C++ Build ? Behaviour
![](http://pubimage.360doc.com/wz/default.gif)
Advanced build settings
4.2.1.3.4. Advanced toolchain specific settings
The tool-chain can be selected form Project ? Settings ?C/C++ Build ? Tool Chain Editor.
To Change general settings of the Tool-Chain, like, enable warnigns(-Wall), don’t include standard system header files during compilation(-nostdinc), etc. go to Project ? Settings ? C/C++Build ? Settings ? Tool Settings
![](http://pubimage.360doc.com/wz/default.gif)
Change general settings of the Tool-Chain
We can also Change the build artifacts (dll/lib/exe). We can control if wewant to build a DLL/Shared Object, static library, or an Executbale out ofthis project.
![](http://pubimage.360doc.com/wz/default.gif)
Change the build artifacts (dll/lib/exe)
4.2.1.3.5. Pre-Build and Post-Build Steps
To Add pre-build and post-build steps, go to go to Project ?Settings ? C/C++ Build ? Settings ? Build Steps
![](http://pubimage.360doc.com/wz/default.gif)
Add pre-build and post-build steps
[1] | Cygwin GCC, Linux GCC, MacOSX GCC, MinGW GCC, Solaris GCC aresupported by default. The Proprietary distributions based onEclipse would also support the toolchains of that distribution. |