More about ELESOFTROM Company

ELESOFTROM Company is specializing in firmware development and fixing for embedded systems.

We have more than 10-years of experience in that area.

In developed tasks and projects we value reliability and effectivness of the firmware.

Fixing the Software for Emebedded Systems

Software for Microcontrollers



Home page

Full offer

Experience

About company

Contact


DioneOS - RTOS for embedded devices

ELESOFTROM developed RTOS for ARM Cortex-M3 and msp430.

The system is optimized for short execution time, having short switching time between threads.
The system provides elements (e.g. semaphores, mutexes, timers, queues etc.) used for building multi-threaded firmware.

Cortex version has full tests coverage and was tested by automatic testing framework.

Read more:

DioneOS home page

Reliability

Performance

DioneOS documentation

Tutorials about DioneOS


How to build C++ Builder project in Eclipse (simple way)

2014-11-05    Piotr Romaniuk, Ph.D.

Contents

Motivation
Borland tools
Tools for the Eclipse
Building from command line
Creation of Eclipse project and building in Eclipse
Error and warning detection
Links

Motivation

I was asked recently for making some changes in large software that was developed in Borland C++ Builder. The software is 10 years old and it is still pactical and in use. Unfortunatelly, when a programmer use Borland C++ Builder 6.0 he can feel little uncomfortable - working in that IDE is not convenient and making any significant modification is painful.

Why not to use some modern IDE, like Eclipse? The programmer can gain all support that helps in development (e.g. dislpaying argument of function durring typing, call hierarchym graphs, graph of header inclussion hierarchy, etc.)

Borland tools

Borland C++ Builder is the IDE (Integrated Development Environment) that is devoted to software creation. From top side (user site) it provides nice graphic interface, from bottom side it uses command line tools (like compilers, linkers, debugger, etc.). These tools can be used in another IDE as well. One should only provide compatibility of call format and received contents (i.e. output console messages). In this way building will be performed by the same compiler, so source files can be untouched (makefiles, Borland libraries).

The installer installs Borland C++ Builder in C:\Program Files\Borland\CBuilder6 by default and included tools in bin subdirectory. One can find there:
- bpr2mak.exe - the converter from project file .bpr to the makefile,
- make.exe - the make program intended to control of build process (note that this is Borland specific),
- cpp32.exe - the C preprocessor,
- bcc32.exe - the C++ compiler,
- tasm32.exe - the assembler,
- ilink32.exe - the linker,

Tools for the Eclipse
In order to have more flexibility and universality I advise to use the MinGW and MSYS - they provide linux-like environment including shell and GNU tools (like make, awk, etc.).
THe tools are installed by default in following directories:
C:\MinGW\bin - the GCC compiler, it will be necessary for determination dependencies on headers,
C:\MinGW\msys\1.0\bin - standard tools (make, gawk, grep, gzip, tar etc.).

Building from command line
When you open the MSYS console (msys.bat in C:\MinGW\msys\1.0\), please change directory to the project one and execute:

$cd /c/Projekty/hello1/
$export PATH=/c/Program\ Files\borland\Cbuilder6\bin:/c/mingw/msys/1.0/bin
$make -f hello1.mak

Powstaną pliki: hello1.exe, hello1.tds, hello1.obj, Unit1.obj
Można uruchomić plik exe i sprawdzić prawidłowe działanie:

$./hello1.exe

Creation of the Eclipse project and building in the Eclipse
In the Eclipse create new project of type: Makefile Project with Existing Code and enter the project directory.
Next, set up build parameters according to following screenshots:





set the definition of __fastcall symbol:



and include paths:



You need to fix the IDE generated hello1.cpp file, just add return type (int) for WinMain function:

//---------------------------------------------------------------------------

#include 
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("Unit1.cpp", Form1);
//---------------------------------------------------------------------------
int  WINAPI WinMain(HINSTANCE, HINSTANCE , LPSTR , int )
{
        try
        {
                 Application->Initialize();
...

When you execute [Build Project] in the Console window (CDT Build Console) you will see building messages:

15:33:13 **** Incremental Build of configuration Default for project hello1 ****
"c:\Progra~1\borland\cbuilder6\bin\make" -f hello1.mak hello1.exe 
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
	c:\Progra~1\borland\CBUILD~1\bin\..\BIN\bcc32 -Od -H=c:\Progra~1\borland\CBUILD~1\bin\..
\lib\vcl60.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c   -tW -tWM -w-par -I"C:\Program File
s\Borland\CBuilder6\Projects";C:\_Projekty\builder2eclipse;c:\Progra~1\borland\CBUILD~1\bin\..\i
nclude;c:\Progra~1\borland\CBUILD~1\bin\..\include\vcl -D_DEBUG;_RTLDLL;NO_STRICT;USEPACKAGES -n
.\ .\hello1.cpp .\Unit1.cpp 
Borland C++ 5.6 for Win32 Copyright (c) 1993, 2002 Borland
.\hello1.cpp:
Loaded pre-compiled headers.
.\Unit1.cpp:
Loaded cached pre-compiled headers.
	c:\Progra~1\borland\CBUILD~1\bin\..\BIN\ilink32 @MAKE0000.@@@
Turbo Incremental Link 5.60 Copyright (c) 1997-2002 Borland

15:33:14 Build Finished (took 910ms)

As the result hello1.exe executable file is created. Unfortunatelly, there is still missing clean option for intermediate and final files. You need to add in the project makefile (i.e. hello1.mak) following rules:

...
.rc.res:
    $(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $<

# ---------------------------------------------------------------------------
clean:
	rm -f $(PROJECT)
	rm -f $(OBJFILES)
	rm -f $(PROJECT:.exe=.tds)
	
all: $(PROJECT)

and enable calling all and clean targets in the IDE:



Error and Warning detection by the Eclipse
The Borland C++ Builder generates warnings and errors in different format than the Eclipse expects:

Borland format
Error E2141 .\Unit1.cpp 21: Declaration syntax error in function _fastcall TForm1::Button1Click(TObject *)
GNU format (recognised by the Eclipse)
ListaKont.cpp:1066:1: warning: W8008 Condition is always true in function Wypelnianie() 

The format can be transformed by the script in AWK (scripts/build_msg_transf.awk) and the script can be inserted in building operation pipe. It is convenient to put it all in a script that set up proper paths. In this way building is set up in the Eclipse by providing a name of the script (build.bat):


Let's make intentionally an error, e.g. by deleting semicolon at the end of line in Umain1.cpp. This cause compilation error and the message is recognized by the Eclipse. You can try this by opening Problems window (see below), clicking on a list on the error. It should move focus to the source file where the error has been detected.



More advanced modification of building process can be found in the description:
How to build Borland C++ Buildera project in Eclipse (using GNU make).

Links

  1. The MinGW project site - download and install MinGW i MSYS
  2. The Eclipse project site - download and install the Eclipse IDE for C/C++ Developers
  3. Source files - examplar project for Borland C++ Builder in the Eclipse
  4. List of errors in Borland C++ Builder