Thursday, September 17, 2009

New Software Development Process, Part 6 - Installing wxFormBuilder, a Form Designing Tool for wxWidgets


Next, I installed the latest version of wxFormBuilder (3.0.57) with the plug-ins for the latest supported controls (wxAdditions). These steps are the ones that I took to install it.

I created the sub-folder
C:\SWDevTools\wxFormBuilder

Then, I created the sub-folder
C:\SWDevTools\wxFormBuilder\download

I downloaded wxFormBuilder_v3.0.57.exe from

http://wxformbuilder.org/?page_id=27

to

C:\SWDevTools\wxFormBuilder\download


I downloaded wxAdditions_Plugin_v2.8.7.02-win32.zip from

http://wxformbuilder.org/?page_id=30

to

C:\SWDevTools\wxFormBuilder\download


Installing wxFormBuilder application is pretty straight forward, I just execute wxFormBuilder_v3.0.57.exe

(I didn't install the source code.)


Installing the wxAdditions plug-ins, requires that you have software to unzip the file wxAdditions_Plugin_v2.8.7.02-win32.zip

I used jZip, which is a free WinZip alternative. If you don't already have software to unzip files, you can get jZip from

http://www.jzip.com/

I opened wxAdditions_Plugin_v2.8.7.02-win32.zip using jZip.

I dragged the wxAdditions folder from the jZip dialog to
C:\SWDevTools\wxFormBuilder\download

Then, I exited from the jZip application.

I opened the "wxAdditions" folder that I dragged from the jZip dialog.

I selected every file in
C:\SWDevTools\wxFormBuilder\download\wxAdditions

I cut everything that I selected and paste them in
C:\SWDevTools\wxFormBuilder\plugins\wxAdditions

Wednesday, September 16, 2009

New Software Development Process, Part 5 - Verifying the Installation of wxWidgets

To test the installation of wxWidgets, I built the "Hello World" program, from wxWidgets web site, using the Visual Studio 2005 and the MinGW C++ compiler.

I created the subfolder
C:\SWDevTools\wxWidgets\test

I point my web browser to the URL
http://www.wxwidgets.org/docs/tutorials/hworld.txt

I copied the source code from this web page and paste it to
C:\SWDevTools\wxWidgets\test\hworld.cpp

I executed Visual Studio 2005 and created a new project.

In the "New Project" dialog, I specified the project to be a Win32 project.

I specified the "Name" of the project to be
test

I specified the "Location" to be
C:\SWDevTools\wxWidgets

I unchecked the "Create directory for solution" option.

Then, I clicked the "Ok" button.

When the W32 Application Wizard" dialog appeared, I clicked the "Next >" button.

For Application Settings", I specified the "Application type" to be
Windows application

I specified for the "Additional options"
Empty project

Then, I clicked the "Finish" button.


I clicked the "Project" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "Project" drop down menu, I clicked the "Add Existing Item..." menu item.

When the "Add Existing Item" dialog for specifying the item to be added popped up, I selected
C:\SWDevTools\wxWidgets\test\hworld.cpp


I clicked the "Project" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "Project" drop down menu, I clicked the "test Properties..." menu item.

I selected the "Configuration Properties" "General" tree item.

For the both the "Debug" and "Release" configurations' "Character Set", I specified
"Not Set"


I selected the "Configuration Properties" "C/C++" "General" tree item.

For the "Debug" configuration's "Additional Include Directories" I specified
$(SolutionDir),$(WXWIN)\include,$(WXWIN)\contrib\include,$(WXWIN)\lib\vc_lib\mswd

For the "Release" configuration's "Additional Include Directories" I specified
$(SolutionDir),$(WXWIN)\include,$(WXWIN)\contrib\include,$(WXWIN)\lib\vc_lib\msw


I selected the "Configuration Properties" "C/C++" "Preprocessor" tree item.

For the "Debug" configuration's "Preprocessor Definitions" I specified
WIN32;_DEBUG;_WINDOWS;__WINDOWS__;__WXMSW__;__WXDEBUG__;WXDEBUG=1;__WIN95__;__WIN32__;WINVER=0x0400;STRICT

For the "Release" configuration's "Preprocessor Definitions" I specified
WIN32;NDEBUG;_WINDOWS;__WINDOWS__;__WXMSW__;__WIN95__;__WIN32__;WINVER=0x0400;STRICT


I selected the "Configuration Properties" "Linker" "General" tree item.

For both the "Debug" and "Release" configurations' "Additional Library Directories" I specified
$(WXWIN)\lib\vc_lib


I selected the "Configuration Properties" "Linker" "Input" tree item.

For the "Debug" configuration's "Additional Dependencies" I specified
comctl32.lib rpcrt4.lib wxmsw28d_core.lib wxbase28d.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexd.lib wxexpatd.lib

For the "Release" configuration's "Additional Dependencies" I specified
comctl32.lib rpcrt4.lib wxmsw28_core.lib wxbase28.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregex.lib wxexpat.lib


At this point, I clicked the "OK" button on the "Property Pages" dialog.


Next, I clicked the "File" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "File" drop down menu, I clicked the "Save All" menu item.


To generate the debug (default) build of the application, I clicked the "Build" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "Build" drop down menu, I clicked the "Build Solution" menu item.


To generate the release build of the application, I clicked the "Build" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "Build" drop down menu, I clicked the "Build Configuration Manager..." menu item and specify the "Active Solution Configuration" to be "Release" and close the dialog.

Then, I clicked the "Build" menu item, from Visual Studio's top menu bar, to obtain its drop down menu.

From the "Build" drop down menu, I clicked the "Build Solution" menu item.


I found, in both the folders

C:\SWDevTools\wxWidgets\test\Debug

and

C:\SWDevTools\wxWidgets\test\Release

the file test.exe

I ran both the test.exe in the "Debug" and in the "Release" folders to verify that the "Hello World" applications work.

Yeah! Both work.


I use the following command to build the executable using GCC MinGW. (all on one line)

g++ -Wall -mwindows hworld.cpp -I%WXWIN%\include -I%WXWIN%\contrib\include -I%WXWIN%\lib\gcc_lib\msw %WXWIN%\lib\gcc_lib\libwxmsw28_core.a %WXWIN%\lib\gcc_lib\libwxbase28.a %WXWIN%\lib\gcc_lib\libwxtiff.a %WXWIN%\lib\gcc_lib\libwxjpeg.a %WXWIN%\lib\gcc_lib\libwxpng.a %WXWIN%\lib\gcc_lib\libwxzlib.a %WXWIN%\lib\gcc_lib\libwxregex.a %WXWIN%\lib\gcc_lib\libwxexpat.a %WXWIN%\lib\gcc_lib\libwxexpat.a %MINGW%\lib\libkernel32.a %MINGW%\lib\libuser32.a %MINGW%\lib\libgdi32.a %MINGW%\lib\libwinspool.a %MINGW%\lib\libcomdlg32.a %MINGW%\lib\libadvapi32.a %MINGW%\lib\libshell32.a %MINGW%\lib\libole32.a %MINGW%\lib\liboleaut32.a %MINGW%\lib\libuuid.a %MINGW%\lib\libcomctl32.a -otest.exe 2>test.lis

I ran the test.exe in

C:\SWDevTools\wxWidgets\test

to verify that the "Hello World" applications work.


Yeah! It works.

New Software Development Process, Part 4 - Installing wxWidgets, the Cross-Platform Application Frameworks

Instead of installing the current stable release of wxWidgets, version 2.8.10, I took a risk and installed the latest development snapshot release, version 2.9.0.

In version 2.9.0, the distinction between ANSI and Unicode builds were removed. Our legacy applications were written with strings using the ANSI/ASCII character set. This new feature, in version 2.9.0, would help us quickly transition our legacy application to Unicode.

Also, version 2.9.0 supports both the 32-bit and 32-bit/64-bit version of Cocoa in Mac OS X.

These two new feature in version 2.9.0 are so critical for us that I was willing to take the risk and not wait (until next year) for the next stable version, with these features, (version 3.0.0) to be released.

While the wxWidgets 2.9.0 build for Visual Studio/Visual C++ was successful, I was not able to build wxWidgets 2.9.0 for GCC MinGW. I was not able to get pass the configure step. In wxWidgets 2.9.0, they eliminated the "contrib" subdirectory but the script for building the WxWidgets library did not reflect the change.

I resorted to installing the current stable release, wxWidgets 2.8.10. These steps are the ones that I took to installed it.


I created the sub-folder
C:\SWDevTools\wxWidgets

Then, I created the sub-folder
C:\SWDevTools\wxWidgets\download

Using my web browser (Mozilla Firefox), I went to:

http://www.wxwidgets.org/downloads/

and clicked on the link to the "Current Stable Release: 2.8.10".

Using the link to "wxMSW - installer for Windows, with manual (other formats: zip)", I downloaded the file "wxMSW-2.8.10-Setup.exe" to C:\SWDevTools\wxWidgets\download


I scanned the file "wxMSW-2.8.10-Setup.exe" for viruses and then executed it.


Specify that wxWidgits be installed in

C:\SWDevTools\wxWidgets

After executing wxMSW-2.8.10-Setup.exe, I set the environment variable

WXWIN

to

C:\SWDevTools\wxWidgets


To switch on wxGLCanvas support on Windows, I edited the setup.h files and set wxUSE_GLCANVAS to 1, before building wxWidgets.

I edited the following files:
C:\SWDevTools\wxWidgets\setup.h.in
C:\SWDevTools\wxWidgets\include\wx\setup_inc.h
C:\SWDevTools\wxWidgets\include\wx\msw\setup.h
C:\SWDevTools\wxWidgets\include\wx\msw\setup0.h
C:\SWDevTools\wxWidgets\include\wx\msw\wince\setup.h
C:\SWDevTools\wxWidgets\include\wx\msw\setup_microwin.h

Note: Make sure to look for all instances of
"#define wxUSE_GLCANVAS"
in each file.


To build wxWidgets for Visual Studio 2005, I opened the Visual Studio/Visual C++ 6.0 workspace file wx.dsw using Visual Studio 2005 and allowed it to convert the project files from Visual Studio/Visual C++ 6.0 format to the Visual Studio/Visual C++ 2005 format.

I selected the "Build" menu item from the Visual Studio menu bar to activate its drop down menu.

From the drop down menu, I selected the "Batch Build..." menu item.

When the "Batch Build" dialog appeared, I selected all the projects that are not DLL projects and are not "Universal" projects.

Then, I clicked the "Build" button.

Since this process will take a long time, I took a lunch break while Visual Studio is building wxWidgets.

NOTE: In the past, I've deployed applications with DLLs and maintaining client's software by updating DLLs. However, more often than not, I've ended up updating almost all the files. Also, these days, everyone has ridiculously huge amount of mass storage space so the amount of disk space saved by the use of DLLs is not really an issue. My cost benefit analysis of the use of DLLs led me to believe that they are more trouble than they are worth. If you disagree, select the DLL projects for the batch build.

NOTE: The "Universal" projects are for when the application GUI will look identical on all platforms. i.e., the GUI does not conform the default style of the operating system GUI "look".

NOTE: Theoretically, I do not need to generate the "release" build of wxWidgets for Visual Studio 2005 since we will be using Visual Studio 2005 only for debugging. We will be using the GCC tools for producing our final products across all the target platforms. However, I've been in software development long enough to know that there will be a time in which we need to deploy a product before we can figure out why the source code can be compiled by Visual Studio 2005 and not be compiled by the GCC compiler. In such a case, we'll deploy the Windows version of the application generated by Visual Studio 2005 and deploy the versions for other platforms when we figure out how to compile the source code with the GCC compiler. So, I generated the "release" builds of wxWidgets for Visual Studio 2005.



To build wxWidgets for GCC MinGW, I executed MSYS from the MS Windows "Start" menu.

Start -> MinGW -> MSYS -> MSYS

When MSys' text terminal window opened, I performed the builds using line commands.


For creating the release/ansi build, I used the following command.

cd /C/SWDevTools/wxWidgets/build

../configure --build=x86-winnt-mingw32 --with-msw --enable-release --enable-ansi --disable-precomp-headers --disable-shared --disable-monolithic -–disable-threads --disable-sockets --with-openGl


cd /C/SWDevTools/wxWidgets/build/msw

mingw32-make -f makefile.gcc MONOLITHIC=0 SHARED=0 UNICODE=0 USE_OPENGL=1 BUILD=release


Since "configure" and "make" take a very long time; I found other things to do while each ran.


NOTE: I built wxWidgets for GCC MinGW without the threads feature; it relies on mingwm10.dll and I don't want to add unnecessary burden to the deployment of our applications. We will employ threading using macros and inline functions defined in the set of c++ header (.h) files that compose the abstraction layer for making operating system calls.

NOTE: I built wxWidgets for GCC MinGW without the sockets feature; the wxWidgets classes for socket communication is too restrictive for the type of network communication uses in our applications. We will perform socket functions using macros and inline functions defined in the set of c++ header (.h) files that compose the abstraction layer for making operating system calls.



For creating the release/unicode build, I used the following command.

cd /C/SWDevTools/wxWidgets/build

../configure --build=x86-winnt-mingw32 --with-msw --enable-release --enable-unicode --disable-precomp-headers --disable-shared --disable-monolithic -–disable-threads --disable-sockets --with-openGl


cd /C/SWDevTools/wxWidgets/build/msw

mingw32-make -f makefile.gcc MONOLITHIC=0 SHARED=0 UNICODE=1 USE_OPENGL=1 BUILD=release

Since "configure" and "make" take a very long time; I found other things to do while each ran.



For creating the debug/ansi build, I used the following command.

cd /C/SWDevTools/wxWidgets/build

../configure --build=x86-winnt-mingw32 --with-msw --enable-debug --enable-ansi --disable-precomp-headers --disable-shared --disable-monolithic -–disable-threads --disable-sockets --with-openGl


cd /C/SWDevTools/wxWidgets/build/msw

mingw32-make -f makefile.gcc MONOLITHIC=0 SHARED=0 UNICODE=0 USE_OPENGL=1 BUILD=debug


Since "configure" and "make" take a very long time; I found other things to do while each ran.



For creating the debug/unicode build, I used the following command.

cd /C/SWDevTools/wxWidgets/build

../configure --build=x86-winnt-mingw32 --with-msw --enable-debug --enable-unicode --disable-precomp-headers --disable-shared --disable-monolithic -–disable-threads --disable-sockets --with-openGl


cd /C/SWDevTools/wxWidgets/build/msw

mingw32-make -f makefile.gcc MONOLITHIC=0 SHARED=0 UNICODE=1 USE_OPENGL=1 BUILD=debug


Since "configure" and "make" take a very long time; I found other things to do while each ran.



NOTE: Theoretically, I do not need to generate the "debug" build of wxWidgets for GCC MinGW since we will be using GCC MinGW only for producing our final products. We will be using the Visual Studio 2005 for debugging. However, I've been in software development long enough to know that there will be a time in which we need to figure out why we are able to compile the source code using Visual Studio 2005 but not with GCC MinGW or why an executable generated by GCC MinGW does not perform the same as the executable generated by Visual Studio 2005 from the identical source code. So, I generated the "debug" builds of wxWidgets for
GCC MinGW.



Sunday, September 13, 2009

New Software Development Process, Part 3 - Installing the GCC Minimal System Utilities

These steps are the ones I took to install the GCC MSys utilities on our Windows/x86 platform.

NOTE: I downloaded the MSys installer while I was installing the GCC compiler tools. (See previous blog entry. http://techadventurer.blogspot.com/2009/09/installing-compiler-tools-for-new.html)

First, I went to the following directory

C:\SWDevTools\MinGW\bin

and rename

mingw32-make.exe

to

make.exe


NOTE: The post install batch command file will rename it back to the original name.



I scanned the file "MSYS-1.0.11.exe" for viruses and then executed it.

Specify the following "Destination Directory"

C:\SWDevTools\MSys

and the following "Start Menu Folder"

MinGW

I continued with the post install.

When it asked for the path where MinGW is installed, I specified the following
c:/SWDevTools/MinGW

NOTE: I used forward slash (under the '?').



To test the GCC Minimal System Utilities, I executed MSys from the "Start" menu.

Start -> MinGW -> MSYS -> MSYS


Its text terminal interface appeared.

At the line command prompt I typed the following commands:

cd /c/SWDevTools/MinGW

ls

cat installed.ini

The "ls" command yielded contents of the directory
c:\SWDevTools/MinGW

The "cat installed.ini" command yielded the contents of the file
installed.ini

MSys was installed successfully.

New Software Development Process, Part 2 - Installing the Compiler Tools

In my next set of blog entries, I will describe the steps I took to install the tools for the new software development process. The first set of tools that I installed are my compiler tools.

I already have Microsoft Visual Studio 2005. For those of you who want to employ the same software development process and don't have Microsoft Visual Studio 2005, you can download a free copy of Microsoft Visual C++ 2008 Express Edition at:
http://www.microsoft.com/express/vc/

These steps are the ones I took to install the GCC MinGW compiler tools on our Windows/x86 platform. Be aware that I chose to use the 2-step installation process:

1) download the software
2) install the software

In the most common installation process, downloading and installing the software is done in one (1) step.

I chose to the 2-step process because I was installing the software on more than one machine. The 2-step process allows me to download the software once for all the machines instead of once for each machine.


First, I created the top-level folder
C:\SWDevTools


Then, I created the second-level folder
C:\SWDevTools\MinGW


I created the sub-folder
C:\SWDevTools\MinGW\download


I created the second-level folder
C:\SWDevTools\MSys


I created the sub-folder
C:\SWDevTools\MSys\download


Using my web browser (Mozilla Firefox), I went to
http://sourceforge.net/projects/mingw/files/

I scrolled down to the item called "Automated MinGW Installer" which has the sub-item "MinGW 5.1.6".


I clicked the sub-item "MinGW 5.1.6" to reveal the sub-items "MinGW-5.1.6.exe"
and "MinGW-5.1.6.exe-src.tar.lzma"

I downloaded MinGW-5.1.6.exe (installer app) to
C:\SWDevTools\MinGW\download

I went back to
http://sourceforge.net/projects/mingw/files/

I scrolled farther down to the item called "MSYS Base System" and clicked on it to reveal the several sub-items. I clicked on the sub-item "Current Release_MSYS-1.0.11" to reveal several sub-items.

I downloaded MSYS-1.0.11.exe to
C:\SWDevTools\MSys\download


I scanned the file "MinGW-5.1.6.exe" for viruses and then executed it.

Select "Download only"
Select "Current" MinGW package

Select the following components to download:

MinGW base tools
g++ compiler
Java Compiler
Objective C Compiler
MinGW Make


I scanned the downloaded files for viruses and then copied them to each PC, that I want to install the development environment, using the same directory structure

C:\SWDevTools\MinGW\download

On each PC, I execute MinGW-5.1.6.exe, again.

Select "Download and install"
Select "Current" MinGW package

Select the following components to download:

MinGW base tools
g++ compiler
Java Compiler
Objective C Compiler
MinGW Make

Specify the following "Destination Folder"

C:\SWDevTools\MinGW


After installing MinGW, I set the environment variable

MINGW

to

C:\SWDevTools\MinGW


Then, I added, to the environment variable, "path", the following:

C:\SWDevTools\MinGW\bin

To test the installation of MinGW, I built the following "Hello World" program using the MinGW C++ compiler.

#include
int main ( int argc , char* argv [] ) {
int inputkey ;
printf ( "Hello World!\n\n" ) ;
printf ( "" ) ;
inputkey = getchar () ;
return 0 ;
} ;

I use the following commands to create the source file.

mkdir C:\SWDevTools\MinGW\test

notepad C:\SWDevTools\MinGW\test\HelloWorld.cpp


I use the following command to build the executable. (all on one line)

g++ C:\SWDevTools\MinGW\test\HelloWorld.cpp -oC:\SWDevTools\MinGW\test\HelloWorld.exe

Double clicking on HelloWorld.exe results in the following output:

Hello World!




MinGW was installed successfully.


New Software Development Process, Part 1 - Introduction, What, and Why



Today, we start developing software using a new development process. In the past, we've maintained, for each application, multiple code bases, one for each target platform. With the new development process, we will maintain, for each application, only one code base, one for all target platforms.

To do so, we will use one set of cross-platform open source software development tools.

For diagramming our application architecture and data structure, we will use Inkscape.

We will use one common set of compiling/linking tools on all our platforms. We will use the tools in the GNU Compiler Collection (GCC). On the Windows/x86 platform, we will use the MinGW version of the GCC tools.

All operating system calls will be made through an abstraction layer composed of a set of c++ header (.h) files that define macros and inline functions with common names across all platforms.

We will also abandon the use of native application frameworks like Microsoft Foundation Class (MFC) and Apple's Cocoa for Mac OS X. Instead, we will use wxWidgets, the cross-platform application framework.

We will use wxFormBuilder to design the graphic user interface (GUI) for our applications.

For rendering graphics, we will abandon use of native graphics APIs like Microsoft DirectX and, instead, use OpenGL, the cross-platform graphics engine.

For accessing data in client/server relational database management systems (RDBMSs), we will use the Open Database Connectivity (ODBC) API. If the customer does not specify a particular RDBMS, we will use MySql.

For simple local databases, we will use SQLite.

There is one exception to the use of open source cross-platform tools. Because all of us are already familiar with Microsoft Visual Studio 2005, we will use it to write and debug our applications on the Windows/x86 platform. Once the debugging is complete, we will build the final product using the GCC compilers on the target platforms (including the Windows/x86 platform).

Here is our software development process:

1) On the Windows/x86 platform, create a project folder for the new application.

2) Create a sub-folder named "Design" for containing the design documents.

3) Design and diagram the application's architecture and data structure using Inkscape and save the diagrams in the "Design" subfolder.

4) Create a sub-folder named "Forms" for containing the design for the application's GUI.

5) Design the application's GUI using wxFormBuilder and save the output in the "Forms" sub-folder.

6) Use wxFormBuilder to generate C++ source code for application's interface with wxWidgets and save them into the "Forms" sub-folder.

7) Copy the wxFormBuilder generated the source code to the top-level project folder.

8) Create the Microsoft Visual Studio project files for the new application in the top-level project folder and set up the newly created project for building a wxWidgets application.

9) Add the WxFormBuilder generated the source code to the newly created Microsoft Visual Studio project.

10) Edit/Build/Debug the code for the new application.

11) When the Microsoft Visual Studio generated executable code works, build the application using the GCC MinGW compiler.

12) When the GCC MinGW generated executable code works on the Windows platform, build the application using the GCC compiler on the target platforms.

We will build applications for the following platforms:

Windows/x86
Linux/x86
Linux/PowerPC
MacOS/x86
MacOS/PowerPC

Saturday, September 12, 2009

Crazy Tech Idea: Personal Electronic Device Charging Pants / Shoes


We waste a lot of kinetic energy when we walk from place to place throughout the day. Some of that kinetic energy can be harnessed and used to charge personal electronic devices such as mobile phones, personal game consoles, music players, etc..

The motion of the legs and feet can be used to move a conductor across a magnetic field to generate electricity. The generated electricity can be stored in batteries. The batteries are connected to inductors in the pockets of the pants.

The personal electronic devices, that have inductors connected to their power supply, can receive the energy, transmitted by the inductors in the pants pocket, and charge their battery with the received energy, when one of these personal devices is placed in the charging pocket of the pants.