Why this post?
Martin Horak helped me to work with Visual Studio (VS) to work with OOFEM. Following his helpful tips I could do the following tasks with VS:
- Run OOFEM from VS
- Debug OOFEM from VS, with very nice tools: highlighting, binding, etc…
I experimented some problems when trying to write my first set of code working under Windows, for example, I couldn’t build OOFEM including LAPACK libraries, while this is pretty straightforward in Linux. This, and also because Linux has some other advantages respect to Windows, I decided to try to configure ECLIPSE to do what I could do with VS.
After struggling with this for several days, I finally could set a configuration that works perfectly (in my case) to run and debug OOFEM under Eclipse, with the same features I enjoyed in VS.
The following steps describe briefly how to do this. The instructions I found useful to do what you can find here where obtained in this link.
All this said, let’s got for it:
Configuring OOFEM in ECLIPSE
-
Before opening ECLIPSE, we need to run cmake to generate all the files that the command make will later need to build OOFEM. To do this, you have to run the following command from the folder where you want to build OOFEM (in this example, the source files are considered to be in ~/OOFEM/oofem.git):
cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug ~/OOFEM/oofem.git
With -G”Eclipse CDT4 – Unix Makefiles” we are telling cmake to use the Eclipse CDT4 build system generator and we need to specify “-D CMAKE_BUILD_TYPE=Debug” if we want to debug OOFEM with gdb inside ECLIPSE.
After this, cmake will generate not only the files that make will need to build OOFEM, but also a .cproject and a .project file that can be imported directly from ECLIPSE.
-
Open ECLIPSE and import the files that cmake has created:
File → Import → Existing Projects into Workspace
In Select root directory, specify where the .cproject and the .project files are.
-
Now we have our project created and only need to build it. To do so, in the Project Explorer, we just have to right-click on the name of the project and select Build Project. After building it, we have a completely operative OOFEM ready to be run and debugged in Eclipse!
Configuring the run/debug modes
The following applies both to the run mode and to the debug mode:
-
Open the Run/Debug configurations (→ Run → Run Configurations…/ Debug Configurations…) and, on the list displayed on the left, select your project under C/C++ Application.
-
In the tab Main:
-
In Project:, click Browse… and select your project (e.g. OOFEM)
-
In C/C++ Aplication:, click Browse… and specify where the .exe file of OOFEM is (it will be in the folder where you have built OOFEM, named “oofem”)
-
In the tab Arguments
-
In program arguments, specify the arguments of your OOFEM launch (e.g. “-f nameoftheinputfile.in”)
-
In the working directory, click on File System… and specify where your input file is. The files generated during the execution of OOFEM will be place in this folder.
- Click Apply and you are done!