= Using Eclipse when developing for MoleCuilder = Eclipse Galileo with the following extensions are ideal for working on MoleCuilder: * CDT >6.0.0 * ECUT >1.0M3 * Eclipse Git >0.5.0 * Linuxtools >0.4.1 Note that some general advice on using eclipse can be found [here http://wissrech.ins.uni-bonn.de/inside/wikka/Eclipse]. == Configuring CDT == We want to create a new project by cloning the git repository from the server that also contains this TRAC. Sadly, Eclipse git does not yet contain functionality to do this. Hence, have a look at GettingStarted to create the project in a folder in the eclipse workspace. Right-click in a free spot in the project explorer, select '''New''', there '''C/C++''' and and finally '''GNU C Autotools Project'''. Click '''next'''. Enter the folder name as the project name, click '''next''' twice, then '''finish'''. Right-click on this new project in the project explorer, select '''Properties'''. We go through each item on the left-hand list and list the necessary changes: === C/C++ Build === In the '''Behaviour''' tab for '''Build''' enter ''all install'' for '''Clean''' enter ''clean''. make sure '''Build on resource save''' is deactivated. Make sure that under the '''Builder Settings''' tab that ''Generate Makefiles automatically'' is activated. Otherwise generation via the autotools process of Makefiles is deactivated! * '''Settings''': You might prefer ''Delete build directory'' over ''Use make target'' as the Clean Behaviour, as ''make distclean'' breaks sometimes if the Makefile is wrongly changed. On the '''Tool Settings''' tab, under '''Directory specifiers''' for '''Arch-independent install directory (--prefix)''' enter a subfolder of your home directory (i.e. /home//install) or use ${workspace_loc:/espack_jupiter/build64} for the build directory. Under '''Features and packages''' enter ''--enable-hydrogen'' ... (and ...'' --enable-cut'' if Ecut is activated, see below). * '''Environment''': Add CFLAGS and CXXFLAGS both with values '''-Wall -g3 -O''', to enable maximum warnings during compilation. === C/C++ General === * '''Code Style''': You may wish to download the code style xml-file from [here CodingGuidelines] and import it here. * '''Indexer''': If eclipse feels very slow, you may wish to change the indexer here. The indexer is responsible for getting you to the right place if you strg-click on a function name or for the tooltips if you hover over a variable or function. Usually '''Fast C/C++ Indexer''' is sufficient. * '''Paths and Symbols''': Under the '''Source Location''' tab enter molecuilder/src (and also pcp/src and util/src as part of ESPACK), remove the default project folder. === Task Repository === The Task repository incorporates the ticket system of TRAC into eclipse. Click '''Add Task repository''', select ''Trac'', enter the default URL of the TRAC, use a sensible label. You have to deactivate ''Anonymous'' enter your user name. Use '''Validate Settings''' to check whether it is working. == Configuring ECUT == Right-click on the project in the project explorer to get the context menu, select '''Ecut'''. Select '''Apply Connector'''. Select the ''!CppUnit Connector'', select ''Create build configuration''. Click '''finish'''. Note: if for ''Create build configuration'' the presence of the same-named configuration is admonished, just select '''No build configuration'''. Two new files should have appeared in the main folder of the project: ''!TestRunnerClient.cpp'' and ''!TestRunnerClient.h''. See above for adding ''--enable-ecut'' to the configure command line and use '''clean project''' and then '''build project''' in context menu of project to re-compile. Under '''Binaries''' in the project explorer a new file called ''!TestRunner'' should have appeared. This file contains all Test cases in a single run. Finally, we configure a run configuration for this new executable. Select '''Run''' from the menu and '''Run Configurations'''. Select ''!CppUnit'' in the list on the left. Click on the '''new launch configuration''' in the icon list above. Give the test a decent name, select your project, use the build configuration you created above (!CppUnitTest) and finally '''Search Project''' for the new executable. Click '''Apply''' and '''Run'''. Note that from now no you can easily access the created Profile by its name in the '''Run''' menu under '''Run as'''. A new tab should appear called !CppUnit with an icon featuring a green letter C and a red letter U. Therein, the errors of the tests are listed. A green bar indicates whether everything ran fine. The green start button re-runs the test executable. Hence, you can re-run tests easily within eclipse to check whether your new code has not broken anything. == Configuring Eclipse Git == Right-click on the project in the project explorer to get the context menu, select '''Team'''. Select '''share project'''. Select ''Git'', click '''Next''' then click on the single line showing a ".git" repository. Click '''finish'''. Eclipse should now display the current branch in square brackets next to the project name in the project explorer. Furthermore, in the context menu, in the '''team''' subitem you find items such as '''Commit''', '''Branch''', '''!ResetTo''', ... resembling some of commands of git for easy use inside eclipse. == Linuxtools == The Linuxtools package contain the support for autotools that we have configured above already, but also support for profilers and code checkers such as [valgrind http://www.valgrind.org/]. Some general remarks on [debugging http://wissrech.ins.uni-bonn.de/inside/wikka/Debuggen] and [profiling http://wissrech.ins.uni-bonn.de/inside/wikka/Profilieren] can be found in the Inside wiki in german. Running valgrind within eclipse has the advantage that memory errors can be directly associated with the respective responsible code lines. Proceed as follows: In the '''Run''' menu, select '''Profile configurations''' to create a configuration of the command you wish to run under valgrind's authority. Select '''Profile with Valgrind''' from the left-hand menu. Click on the '''new launch configuration''' in the icon list above. Give the test a decent name, e.g. ''Valgrinding !TestRunner'', select your project, use the build configuration you created above (!CppUnitTest) and finally '''Search Project''' for the new executable, here ''!TestRunner''. If you need to run more complex commands, arguments and can be given in the '''Arguments''' tab. In the '''Valgrind options''' command line options of valgrind can be specified. You might want to change the '''Leak resolution''' there to ''full'' and check the '''Show reachable blocks''' for full report on memory leaks and reachable adresses. Also make sure to have your Project listed in the '''Source''' tab, if not '''Add''' it. Click '''Apply''' and '''Profile'''. Note that now you can easily access the created Profile by its name in the '''Run''' menu under '''Profile as'''.