Using Codelite for Windows Mobile development

This article describes how to use CodeLite IDE with EVC++ compiler and linker, but it should be similar with others IDEs.

I assume you already have downloaded and installed EVC++, EVC++ SP4 and Pocket PC 2003 SDK. I also assume you have CodeLite installed and compiled at least one PC program with it.

EVC++ command line

There are three commands we will be using: 

  1. compiler - clarm.exe
  2. linker - link.exe
  3. makefiles - nmake.exe

First let's create makefile. Create some file, it doesn't really matter what's its name (I called it makefile, without any extension), and put following conten in (read every line which begins with # to know, what you should replace):

# place all source files on the next line after SRCS=
SRCS=main.cpp Board.cpp GameEventHandler.cpp
# place all obj files on the next line after OBJS=
OBJS=tmp\main.obj tmp\Board.obj tmp\GameEventHandler.obj
#place all used libraries on the next file after LIBS=
LIBS=gx.lib FLib.lib

CECrt=C
CECrtDebug=C
CECrtMT=C
CECrtMTDebug=C
CENoDefaultLib=libc.lib /nodefaultlib:libcd.lib /nodefaultlib:libcmt.lib /nodefaultlib:libcmtd.lib \
	 /nodefaultlib:msvcrt.lib /nodefaultlib:msvcrtd.lib
CEx86Corelibc=corelibc.lib

!IF "$(CE_PLATFORM)"==""
CePlatform=WIN32_PLATFORM_UNKNOWN
!ELSE 
CePlatform=$(CE_PLATFORM)
!ENDIF 

!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE 
NULL=nul
!ENDIF 

#change OrinSquares.exe to name you want on next line
ALL : OrinSquares.exe
 
CPP=clarm.exe
CPP_PROJ=/nologo /W3 /GX /D _WIN32_WCE=$(CEVersion) /D "$(CePlatform)" /D "ARM" /D "_ARM_" /D "ARMV4" \
	 /D UNDER_CE=$(CEVersion) /D "UNICODE" /Fo"tmp\\" /D "_UNICODE" /D "NDEBUG" /O2  /M$(CECrtMT) /c 

{src\}.cpp{tmp\}.obj:
   @echo Compiling
   @$(CPP) $(CPP_PROJ) $<
	
LINK32=link.exe
LINK32_FLAGS=$(LIBS) commctrl.lib coredll.lib aygshell.lib  /nologo /base:"0x00010000" /stack:0x10000,0x1000 \
	 /entry:"WinMainCRTStartup" /incremental:no /pdb:"OrinSquares.pdb" /nodefaultlib:"$(CENoDefaultLib)" \ 
	 /out:"OrinSquares.exe" /subsystem:$(CESubsystem) /align:"4096" /MACHINE:ARM 

#change OrinSquares.exe to name you want
"OrinSquares.exe" : $(OBJS)
  @echo Linking
  @$(LINK32) $(LINK32_FLAGS) $(OBJS) /out:bin\OrinSquares.exe
  
clean: 
  erase /Q tmp\*
  erase /Q bin\*

There are not any more details about makefile syntax here, so can look somewhere else if you want to understand it.

Before we can user compiler, linker and makefiles, we need to set an enviroment for these tools (paths, configuration). There is already a batch file for this task called WCEARMV4.BAT. It is located in `EVC++ install directory`\EVC\wce420\bin (I installed EVC++ in C:\Program Files\Microsoft eMbedded C++ 4.0 so the full path of this batch file is C:\Program Files\Microsoft eMbedded C++ 4.0\EVC\wce420\bin\WCEARMV4.BAT)

Now we are able to create batch file which compiles our projects.

 

call "C:\Program Files\Microsoft eMbedded C++ 4.0\EVC\wce420\bin\WCEARMV4.bat"
nmake /f "makefile" CEVersion=502 CESubsystem=windowsce,5.02 

The next step is create new CodeLite project. When creating new project select project type: Simple executable (MSVC).

After you created new project and added your source files open project settings, tab Custom build and enter path to our batch file.

All is set and if you click on build active project your project is build using makefiles.


Discussion:
Add post