Eclipse supports two modes: the "Managed Make" and "Standard Make" modes. In general, if you are intending to do all of your development from within Eclipse, you should use the Managed Make mode. In this mode, Eclipse will automatically handle building your project for you. However, if you are working with code that has previously been built with make, you may wish to use the "Standard Make" mode instead.
Start Eclipse and create a ARM Sourcery G++ Lite project by selecting C++ label and select Managed Make C++ Project. (To build a C application, expand the C label instead.) Click the button. Give the project the name "hello" and click the button. From the menu select Executable (ARM Sourcery G++ Lite for ARM GNU/Linux) and click . If you are asked whether or not to open a new perspective, click the button.
→ → . Expand the
Next, select
hello.cc
and click
. Paste the following code into
the file:
Example 5.1. Hello, World (C++)
#include <iostream> int main () { std::cout << "Hello, world!" << std::endl; }
As soon as you save the file, Eclipse will build the program. The
executable itself will be located in a subdirectory of the Eclipse
workspace directory named hello
. Of
course, the executable will run on the target system, so if you are
targeting an embedded system, you will have to upload the
executable to the target system before running the application.
Using Standard Make Mode requires that you manually maintain information about how your program is built. If you use this mode, you will need to be familiar with the make utility.
If you want to import an existing project for use with Eclipse,
and that project uses make, or some similar
command-line tool to manage the build process, you should use a
Standard Make project, instead of a Managed Make project. In
Standard Make mode, Eclipse will invoke make
(or an alternative program that you specify) to build your
program. If you add new files to your project, you will have to
manually update the Makefile
for your
project.
To set up the Standard Make mode to work with ARM Sourcery G++ Lite, you will have to make a few changes to the default Eclipse project settings. When you are creating the project, you will be presented with a window that permits you to define the project settings.
Select the Discovery Options tab and set the
Compiler invocation command to
arm-none-linux-gnueabi-gcc instead of the default
gcc. That change will tell Eclipse to use
ARM Sourcery G++ Lite when scanning your program code to determine
cross-rereference information. You may also have to adjust your
Makefile
to use ARM Sourcery G++ Lite. For example, you
might need to set the CC
variable in your
Makefile
to
arm-none-linux-gnueabi-gcc.