CPP+development+with+Eclipse

toc =Introduction= Program development for both host and target can be done using [|Eclipse]. Eclipse Galileo including C/C++ Development Tools (CDT) are preinstalled on the Golden VMWare Image. The installation of Eclipse is therefore not covered here, but it is quite simple to set up.

In this article you will find information on how to set up Eclipse for development of C/C++ applications and device driver modules for target. =Procedure for C++ Applications=

1. Create and build a C++ project for host
Start Eclipse by the command. Then create a new C++ project (File > New... > C++ Project), add files and compile the project.

2. Create a new build configuration for target
By default, your project already contains two //build configurations//, and. For each of these, you can set up how to build them etc. We will create a third Build Configuration, Which we will set up to build the C++ project for the DevKit8000.

1. Right-click your project, select "Build Configurations > Manage...". Then select "New..." 2. Name the configuration "Target" and add an optional description. 3. Select "OK" 4. Right-click your project again, select "Properties > C/C++ Build > Settings" 5. Select "Target" from the "Configuration" drop-down menu 6. In "Tool Settings", change the following (Always check whether this in fact is your compiler... it might have gotten a new name): 7. Right-click your project, select "Build Configurations > Set Active > Target" 8. Build your project
 * For "GCC C++ Compiler", change to
 * For "GCC C Compiler", change to
 * For "GCC C++ Linker", change to
 * For "GCC Assembler", change to

Your target executable is now in the subdirectory of your project directory. Transer this file tio target and execute it.

When you have created a build configuration once...
For each application you whish to make for target you will need to set up a build configuration for target. However, when you have followed the above procedure once, subsequent build configuration definitions can be simplified somewhat: In Step 2 above, when you name your configuration you can also import build settings from an already defined project. If you do so, you will not need to do steps 4-6. Instead, you will probably want to change the name of the output (executable) file:
 * Right click your project and select "Properties".
 * Under C/C++ Build > Settings, ensure that your target configuration is selected in the "Configuration" drop-down box, then select the "Build Artifact" tab and change the artifact name.

Libraries etc. under Eclipse
To use libraries, e.g. under Eclipse, add them as  (e.g. ) under Properties > C/C++ Build > Settings > GCC C++ Linker > Mischellaneous > Linker flags

=Procedure for Linux Kernel Modules= Linux kernel modules are trivial C programs. They do however refer to a lot of stuff in the kernel tree and need special makefiles, so we have to create a special type of project for it to work in Eclipse.

1. Have a Makefile and source file that compiles at the prompt.
This is a good start. See the Makefile example below: code format="make" ifeq ($(KERNELRELEASE),) KERNELDIR = /home/stud/source/linux-2.6.28-omap PWD := $(shell pwd) TEMP := $(shell echo $(TARGETKERNEL))

all: $(MAKE) -C $(KERNELDIR) M=$(PWD) modules clean: rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions

.PHONY: modules modules_install clean else obj-m += lm75mod.o   lm75mod-objs := lm75.o lm75-core.o lm75-i2c.o endif

code

2. Create a new C project
In Eclipse create a new C project using the wizard. Choose Makefile Project->Empty Project and a suitable name for the project. Press next at push the "Advance Settings" button. In the C/C++ General->Paths and Symbols pane, pick "GNU C" and press add. Now choose file system and pick the following folder: /home/stud/source/linux-2.6.28-omap/include, Tick "Add to all configurations" and press OK Similar pick the following folder: /home/stud/source/linux-2.6.28-omap/arch/arm/include, Tick "Add to all configurations" and press OK Press the "Symbols" tab and add a symbol named "__KERNEL__" it needs to have no value. Tick "Add to all configurations" Press OK. Press OK to return and press finish.

3. Import your files
Your new project will now appear in the project pane. Right-click on the project and choose "Import" Pick General->File System and press next Choose the folder with your existing Makefile and source files Pick .c .h and Makefile and press OK. The files are now copied into your project directory.

You are now ready to compile and have indexed kernel functions such as printk etc.

See [|http://www.on5di.com/~noel/eclipse/kernelmodules.html] for details