Login | Register
My pages Projects Community openCollabNet

Introduction


This document contains information about how to compile your first "pure C++ program" using the tools and libraries from the Ligthblue Project. LightBlue provides a set of tools and libraries that make it possible to write abosolute object-oriented C++ programs for the BREW platform; Brew Interfaces are mapped into C++ abstruct classes and could be used and inherited as ordinary C++ classes.



Lightblue Components

The LightBlue project contains following tool(s) and librarie(s):

Headergen.exe    A command line utility that parse the C header files from the orginal BREW SDK and generate C++ class declarations.
Runtime               A  very small  C++ runtime code  that replace AEEAppGen.c and AEEModGen.c from the original BREW SDK. C++ Programs should link with this runtime instead of including AEEAppGen.c and AEEModGen.c.

Since all other programs including the Runtime  reference C++ class declarations generated by Headergen.exe, we should compile it first if it is not included in the LightBlue distribution.

 

Tools needed

Following  software are needed in order to build Lightblue:
  1.  The visual studio 2003
  2.  Brew SDK 2.1.3 
  3.  GNU ARM Compiler
  4.  BREW Plugin for Microsoft Visual Studio
Note:

The only Brew SDK tested is 2.1.3 at this moment,  but all versions after 2.0.0 will be supported eventually.
'1' is needed only when you want to compile Headergen.exe or build libraries or executables for the BREW emulator.
'3' and '4' are needed only for  generate libraries and executables for the real hardware.

How to build Lightblue

Assume that you have downloaded and extracted Lightblue into a local directory $(BL_ROOT), you need following steps to  make Lightblue ready to use:

step1: Compile HeaderGen.exe
  1. Open $(BL_ROOT)/src/VSProjects/LightBlue/HeaderGen/HeaderGen.vcproj with visual studio 2003 and press the compile button in the visual studio IDE. This will generate HeaderGen.exe in $(BL_ROOT)/ src/VSProjects/LightBlue/HeaderGen/Debug directory.
  2. copy $(BL_ROOT)/src/VSProjects/LightBlue/HeaderGen/Debug/HeaderGen.exe into $(BL_ROOT)/utils
step2: Generate C++ declarations using HeaderGen.exe
  1. Edit tool path in $(BL_ROOT)/env.bat to reflect you current  system  configuration.
  2. Run $(BL_ROOT)/utils/buildheader.bat. If successful, 52 hpp files will created in $(BL_ROOT)/include/brewpp/ directory.
NOTE: There is a file called missing_method.txt created which lists all BREW Interface methods that are not mapped to C++ classes. Currently, there are around 105 BREW Interface methods that are not be sucessfully mapped. These methods are not part of the actual v-table. The later version of HeaderGen will reduce this number eventually to zero. Please check the doucment Why there are missing methods? 

step3: Compile the runtime for the emulator
  1. Make sure all 52 hpp files are generated in $(BL_ROOT)/include/brewpp/  and missing_method.txt contains less than 105 lines.
  2. Open $(BL_ROOT)\src\VSProjects\LightBlue\RunTime\RunTime.vcproj with visual studio 2003
  3. Edit Project properties: C/C++ -> General -> Additional Include Directories,  update the absolute directory to you current BREW SDK installation directory.
  4. Compile the library using Debug configuration. There are some warnings that come from the original BREW SDK header files, you can safely ignore them.

NOTE: After a sucess build, Following files are created:

$(BL_ROOT)\include\brewpp_runtime\AEEimp.hpp
$(BL_ROOT)\include\brewpp_runtime\brewpp.hpp
$(BL_ROOT)\lib\vc\debug\entryptr.obj

Due to an bug in the current version of Headergen.exe, when you compile the runtime library, the compiler will report two errors that come from the inline method IBrewUnzipAStream::cancel() and IBrewAStream::cancel(), please comment this two methods. (The later version of HeaderGen will remove these two methods automatically.)

step4: Compile the runtime for the real hardware
      
  1. Make sure all 52 hpp files are generated in $(BL_ROOT)/include/brewpp/  and missing_method.txt contains less than 105 lines.
  2. Edit tool path in $(BL_ROOT)/env.bat to reflect you current  system  configuration.
  3. run $(BL_ROOT)/src/runtime/build.bat
  4. run $(BL_ROOT)/src/runtime/install.bat
NOTE: After a sucess build, folllowing files are created:
$(BL_ROOT)\lib\g++\entryptr.o

How to compile the helloworld example program

Step1: Make sure that  following  files  are  sucessfully generated (If they are not there, please build Lightblue first ):

$(BL_ROOT)\include\brewpp_runtime\AEEimp.hpp
$(BL_ROOT)\include\brewpp_runtime\brewpp.hpp
$(BL_ROOT)\lib\vc\debug\entryptr.obj
$(BL_ROOT)\lib\g++\entryptr.o

Step2:  Edit tool path in $(BL_ROOT)/env.bat to reflect you current  system  configuration.

Step3:   Compile  code  for  the  emulator:
  1. Open  $(BL_ROOT)\Examples\HelloWorld\HelloWorld.vcproj
  2. Edit project properties: c/c++ ->general -> Additional Include Directories:   set the absolute directory to you BREW SDK Instalation directory.
  3. Compile the project
The output executable: helloworld.dll in created  in the same directory as the source code,  you can  now  open the  BREW  emulator and  change applet dir to $(BL_ROOT)/examples.

Step4: Compile code for the real hardware:

Run $(BL_ROOT)\Examples\HelloWorld\build.bat

The output executable: helloworld.mod is created in the same directory as the source code, you can nowcopy this file along with a mif and sig file to the phone.