Wednesday, December 12, 2012

MPLAB X IDE So Slow and takes for EVER

Anyone can help with this would be great.  It was working fine for ever, then suddenly it started to take forever when I connect to the board to download FW or edit project settings.

I now I installed some Java for Android development recently and this is about the time it started to do this...
What part is causing this I am not sure yet...


Some of the things I did so far and did not work:

  1. I changed the path to  jdkhome=""  in the following file  "C:\Program Files (x86)\Microchip\MPLABX\mplab_ide\etc\mplab_ide.conf"
  2. I also, added the switch to the start-up icon "C:\Program Files (x86)\Microchip\MPLABX\mplab_ide\bin\mplab_ide.exe" --jdkhome "C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64\java-windows"




This is not good, it is killing me, I can not do any development like this...

Updates: 12/13/2012:
It was something with my Bluetooth.  I started working on Bluetooth around the same time when MPLAB started acting this way.  So, I thought to disconnect my BT dongle, and walla, MPLAB working just fine!!  Something was going on between BT dongle and MPLAB.  I will have to find out!

Monday, December 10, 2012

Configure Eclipse to Auto-Save before Executing App

So, if you develop using  Eclipse, you must know how you have to save your modules every time you click on run.  So, it is an extra click every time.  Usually in most other IDEs you would not have to do this, because they have an option to auto-save your modified documents.

I know there was an option in Eclipse too, and I used it before but, I forgot how to do that and it took me a while to find it again.
so, here it is, a note to my self and to others who need to know how...

Click on Window -> Preferences
Select General from the list on the left
Expand it and click on Workspace
In the right side make sure the "Save automatically before build" is checked



Now Select Run/Debug from the list on the left
and Expand it to Select Launching
In the right side find and make sure "Save required dirty editors before launching" is Always



Click OK and you are set to go.



Tuesday, December 4, 2012

Do you get this message: "javadoc java platform manager"

If you are using NetBeans and writing Java applications, you try to get some information on functions or properties details and you get this message, "javadoc java platform manager". Then you most likely missing some Documentation from Java JDK.




Try and delete this folder first after backing it up some where:
/home/elsaghir/.netbeans/7.0/var/cache

Here is what you need to add:
sudo aptitude install openjdk-6-jdk
sudo aptitude install openjdk-6-doc

replace the number 6 with the latest revision of java at this time...
you should see new data and folders in this folder 
/usr/lib/jvm/default-java/docs

How to: Retrieve Time in C++ OR Calculate Elapsed Time


Here are few different methods to retrieve time in C++ depends on your requirements

I always need to retrieve time information one way or anther to use in my code. so I decided to create this Knol to keep/list all methods and related information for everyone so we can retrieve this easier in the future!




/*
The Goal of this project is to be a reference to all Date and time stuff
Author: Hesham Elsaghir
Date: 10/13/2010
*/
#include"stdafx.h"#include "iostream"#include "time.h"#include "atltime.h"
using namespace std;

int  _tmain(int argc, _TCHAR* argv[])
{
SYSTEMTIME st;
FILETIME ft;

unsigned short File_Time_Date;
unsigned short File_Time_Time; // time and date in numbers format...

GetLocalTime(&st);

SystemTimeToFileTime(&st, &ft);
cout << "Today's Day # is: " << st.wDay << endl;
cout << "Today's Month # is: " << st.wMonth << endl;
cout << "Today's Year is: " << st.wYear << endl;
// This function will convert the time and date to Dos Date and Time format
FileTimeToDosDateTime(&ft, &(File_Time_Date), &(File_Time_Time));
cout << "Time now in File time is: " << File_Time_Time << endl;
cout << "Time now in File Date is: " << File_Time_Date << endl;
// This is a different method to obtain Date and Time
struct tm now;
time_t time_now;
time(&time_now);
now = *localtime(&time_now); 
/* Get time and date structure */mktime(&now);
cout << "Time now is: " << now.tm_mon << now.tm_mday << now.tm_year << endl;cout << "Ctime format to time: " << ctime(&time_now) << endl;

long time_taken = clock();
printf(
"%ld\n", time_taken);
printf("%d\n", CLOCKS_PER_SEC);
// How to use sscanf() to int day, month, year;
char test[] = "10/3/2010";
sscanf(test, "%d/%d/%d", &day, &month, &year);
printf(
"day: %02d\n",day);
printf(
"moth: %02d\n",month);
printf(
"year: %04d\n",year);
// Here is a way to print local and Gtime "UTC"struct tm *local;
time_t t;
t = time(NULL);
local = localtime(&t);
printf(
"Local time and date: %s\n", asctime(local));
local = gmtime(&t);
printf(
"UTC time and date: %s\n", asctime(local));

// Using sprintf to write a formated string into an array
GetLocalTime(&st);
char temp_mdy[50];
sprintf(temp_mdy, "    @date       %02d/%02d/%04d\n",st.wMonth,st.wDay, st.wYear);

cout << temp_mdy << endl;


// Different methods to capture time elapsed
long st_time = clock();
// do some work here
Sleep(500);             // sleep 500 milliseconds
long sp_time = clock();
printf("Time Elapsed is: %ld Millisecond\n", sp_time - st_time);
// Or you can use this
time_t time_1, time_2;
time(&time_1);
Sleep(10000);                 // sleep 10 seconds
time(&time_2);
printf("Time Elapsed is: %.2lf seconds\n", difftime(time_2,time_1));


return
 0;
}

Here is the output of the program:
 



I will be adding more futures to cover C# later.

References:
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

How to convert a Structure to byte array

So many times we need to use a structure to hold and organize some data. Then later we will need to send this structure to a client or another system via serial or ethernet. C# is not a very cast friendly! so you can't just cast the structure to a byte array like you can do in C or C++.





I have this strucure for example.
struct str_packet
{
    byte           key;
    byte    []    offset;
    byte          length;
    byte    []    data;
    short         Check_Sum;
};
 
 
 
 
 /*
    This Function will return a Byte Array that contains the data in the structure
*/ 
static byte [] StructureToByteArray(object obj)

{
    int len = Marshal.SizeOf(obj);
    byte [] arr = new byte[len];
    IntPtr ptr = Marshal.AllocHGlobal(len);
    Marshal.StructureToPtr(obj, ptr, true);
    Marshal.Copy(ptr, arr, 0, len);
    Marshal.FreeHGlobal(ptr);
    return arr;
}
/*
This Function will set a pointer to the new data extracted from the Byte Array
*/
static void ByteArrayToStructure(byte [] bytearray, ref object obj)
{
    int len = Marshal.SizeOf(obj);
    IntPtr i = Marshal.AllocHGlobal(len);
    
    Marshal.Copy(bytearray,0, i,len);
    obj = Marshal.PtrToStructure(i, obj.GetType());
    Marshal.FreeHGlobal(i);
}

Useful Linux Console Commands and tricks

Every day I learn a new command or trick and then if I do not use again or I need it later I search for it again and spend a lot of time on that. So, I know the best efficient way to track knowledge we learned is by writing it.


List of Commands I find while I am working and I hope this will help me later and you too!



"dmesg"'  Print or Control the Kernel ring buffer
That is to print the bootup messages.  and you can direct the output messages to a file by using 
dmesg ? boot.messages
Then use a text editor to view that output
You can also use
dmesg | grep sometext
where some text is any text you searching for in the output of dmesg.  so if you searching for tty occurrence in booting up process you need to type   dmesg | grep tty

who  will list all users logged in to the same


cat  >  file_name.txt   Will create the file name and allow you to enter text and save it

which find out what a command path is.
for example, use
which adduser  -->  the return should be /bin/adduser
or
which passwd   -->  the return should be /usr/bin/passwd


passwd  to change your password or another user password


nano is a great editor if you have a basic linux console and do not have the GUI

tar     un-tar a compressed file
use tar xvjf \path_to_file_with_ext_.tar.bz2
use tar -zxvf \path_to_file_with_ext_.tgz



Some Good References:
https://help.ubuntu.com/community/UsingTheTerminal

Using GNU Octave to solve symbolic Equations


GiNaC is the Symbolic package for GNU Octave


I have been trying to move completely to use GNU Octave instead of using Matlab.  Matlab is a high-level programming language for working with matrices and is very widely used now by Engineers and other fields for calculations and analyses.  The issue is Matlab is very expensive package to own and not everyone can install it on his/her personal computer.  Moreover, now that I use Ubuntu Linux as my main OS, Hello to the Free world and goodbye to other OS ties and limitations, I can not run Matlab anyway on Ubuntu.
So, I use GNU Octave to perform all my calculations and code algorithms I need.  I just realized that I need to do some symbolic calculations and I know what I need to do that in Matlab
    syms x
or
    x =  
sym("x")
and that is enough for what I need.  I come to find out that it does not work for GNU Octave.  So, to make the long story short , here is what you need to do to get that working
when installing GNU Octave I used this command
    sudo apt-get install octave3.2 octave3.2-common octave3.2-doc octave3.2-dbg
This will install all what you need to install Octave.  but you still missing one package
    sudo apt-get install octave-symbolic
This is the package that contains GiNaC support for symbolics.

Here is a simple example to show you how to use it in GNU Octave:

% This is an example to show you how to calculate total value to two resistors in parallel
octave-3.2.3:1> symbols        % Initialize symbolic manipulation
octave-3.2.3:2> R1 = sym("r1")
R1 =

r1
octave-3.2.3:3> R2 = sym("r2")
R2 =

r2
octave-3.2.3:13> Z = (R1 * R2)/(R1 + R2)
Z =

(r2+r1)^(-1)*r2*r1
octave-3.2.3:14> subs(Z, {R1, R2}, {10,10})  % substitute the R1, R2 values with 10 Ohms each
ans =

5.0

Please, Leave me comments or opinions about what you think, Thanks,

How to configure your iPhone to work with Gmail


Using your Gmail Email, Contacts, and Calendar on your iPhone

Well, with the new iPhone OS 4 you can link your email application on your iPhone to your Google account resources. If you make use of Google Email "Gmail", Google contacts, and Google calendar, now you have access to all three resources from you iPhone. But, you need to configure your phone first.




To start you need to know that you can not have more than one exchange account configured on your iPhone.  What that means?  Well, we are going to connect to your Google account via Microsoft Exchange tool on your iPhone, and it can only be configured to use one account.  So, we can only have one account of this type.
Steps to configure your Google account:
  1. Go to your iPhone and tap Settings
  2. In Settings find "Mail, Contacts, Calendars" and tap it
  3. Find "Add Account..." at the bottom of the Accounts Section and tap it
  4. You will see the following screen capture


  5. Tap "Microsoft Exchange" to Configure it
  6. You will need to enter the following items as shown in the following screen capture:
    1. Your Google email account address
    2. Server name: n.google.com
    3. Domain: Leave blank
    4. User name: Enter your Google email address again
    5. Password: Enter your Google Email account password
    6. Description: A Description will be filled for you, you can change it if you want
    7. Use SSL:  Make sure it is ON
    8. Once you are done, confirm your settings and you should get a screen asking to choose what services you want to enable Mail, Contacts, and Calendar
      1. .
    9. You are done, you should be able to access all your Google resources from your iPhone.

More details to be added...
 



 
 
Links to Web sites:

Concerns About Button Layout in Ubuntu Lucid

I am used to see my close, minimize and maximize buttons on the top right side of my windows, so when I go to change the window state I always hid to the that top right corner, but nothing is there any more. Do you want to know how to bring them back HOME?



As simple as follow:
  • run a command by going to a Terminal Window or Alt+F2
  • Type gconf-editor
  • You will see the Configuration Editor Screen shown below
  • Look for /apps/metacity/general/button_layout
  • You should see something like close, minimize, maximize:
  • All you need to do is move the colon : from the end of the line to the beginning of the line and press Enter
  • VOILA!, that is all about it
  • You can explore more in Configuration Editor to learn about what other option you can control "Only if you are comfortable with that"




Warring, Changes will take effect Immediately, if you do not know what you just changed you could experience system miss-functioning.  Do it at your own risk.

All About Ubuntu Network Configuration


The Console Commands

Have you ever wondered what is the equivalent to ipconfig /renew /release in Ubuntu Linux? I collected all the information I thought about related to Ubuntu Network in this Knol. If you have any other questions or suggestions, please, let me know.



So, to start, here is the common question.
1)  How can I start restart my network?
Well, in Ubuntu you can bring the network down and up using these commands
ifup, ifdown you will need to supply the network interface you trying to restart so,
 
Restart Network Interface #0 Restart Network Interface #1
ifdown eth0
ifup eth0
 ifdown eth1
ifup eth1
Also, you can use one of the following commands to start. stop, or restart the networksudo /etc/init.d/networking start
sudo /etc/init.d/networking stop
sudo /etc/init.d/networking restart

How would you know what is the ethx number for your N
etwork Interface?
  you can type
ip addr show OR
sudo ifconfig -a
this command will display all your network interfaces with their information.  Usually you will have lo and eth0 or eth1.  The lo is your loopback interface and always has the IP Address 127.0.0.1 and a MAC address of 00:00:00:00:00:00
 
.  However, the other Network interface will have the label link/ether and that is what you need to work with.
There is also ifconfig which will give you more information on your network and still will sort the information by Network interface lo and eth0.  If you are not interrested in lo network interface as I do most of the time, you can type  ifconfig eth0  so you do not have to see the other interfacce information.
 
2)  The next question is, how can I configure my network to use a proxy?
Well, Ubuntu looks for a file in /etc/apt with the name apt.conf  so you need to create this file if it does not exist.  and if it does, you can edit it with root access using the program nano, which is a very nice simple editor.
you will need to enter the following line
 Acquire::gttp::proxy "http://xyz.xyz.zyx:portnumber";
for example this is a link to proxy with URL, http://www.google.com and uses port number 3456.
 
 Acquire::gttp::proxy "http://www.google.com:3456";
 
 3) How to connect/map a network share on my Ubuntu session?
This done by using the command smbclient.  Make sure smbclient is installed on your system first.  All you need to do is type smbclient and if you get an error not found, then just install it.
sudo apt-get install smbclient
Then you can type  smbclient //server/name/share -U username
You will be prompt for a your password on this server and a prompt like this
smb: \>
Now you can start typing your commands or Type  ?  for command list.
 
There is also, sudo mount -t cifs  that will give you the option to map to a network share.
 
 
More to be added,
 
 
 
References:

Install AVR32 Studio and GNU on my Ubuntu 10.04 Lucid


As Usual, I like to update my Ubuntu with the latest release even if it is still in beta stage. But there is a price to pay. When I wanted to install AVR32 Studio and GNU it did not work and returned an error that there are few libraries missing. Here is what I did to get it to work.


Install the following items in this order:
To get the library packages in blue, you will need to visit Ubuntu Package site and download them.  Make sure you download the correct version number for the package.
Avr32-binutilsAvr32-gcc-newlib
Avr32-gdbAvr32-buildroot-essentials           need network connection
 
Libboost-system1.38                  karmicLibboost-filesystem1.38              Karmic
Libboost-thread1.38                    KarmicLibboost-filesystem1.34.1           Karmic
Libboost-thread1.34.1                 Karmic
Libavrtools_                               GNUAvr32parts
Libavr32ocdLibavr32sim
LibelfdwarfparserAvr32trace
Avr32programAvr32headers
 
Libboost-date-time1.34.1         Karmic 
Avr32gdbproxy
Avrfwupgrade
Avr32-gnu-toolchain


Java stuff:   you will need to install Eclipse or just install Openjre.....
I have to add more details here

How to Add Folder Browser Dialog Option to Your C# CSharp Program


I am writting these programs in C# "C Sharp" and always needed to give the user the option to select a folder.  Well, this should not be a segnificant task.  Dialog folders are always been provided by the toolbox in Visual Studio, Open, Save, Print, Font, etc...  so the Folder Browser should not be an issue.  So, I spent all day looking for a way to give the user the option to select a folder in my program.  search all over the internet and all blogs.  found a lot of feed back, but wow, that was so much to do to add this little option to my program.   So finally I look in my toolbox components and I saw it.  the Folderbrowserdialog component.  it is there!!!
 
all you have to do is add this to a button click: 
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
Selected_Folder_Button.Text = folderBrowserDialog1.SelectedPath;
}
I can not believe all that talk out there on the internet and complecated feed back, this is two lines of code!!!!

Installing VirtualBox Guest Additions on Debian


Step-by-Step procedure

I use Vbox a lot with my research, development, and testing with linux Ubuntu. I installed the guest additions no problem just by running the VBoxLinuxAdditions-x86.run. I happed to need Debian as one of my VirtualBox images to do some testing with it. I like to have the guest additions installed as it makes life much easier to switch between the host computer and the guest window. chocking I could not, no matter what, get that guest additions to install. After a lot of research and reading here is what I had to do to get it installed.

The following process is done on the Guest OS not the Host OS.
  1. Start a terminal and su to root.  working with sudo will not help at this time
  2. Update your system APT database by using apt-get update then apt-get upgrade
  3. Also make sure you do aptitude update then aptitude upgrade
  4. Run the apt-get upgrade  to install the latest security needed for your system 
  5. Install the required packages for the guest additions by running
    • apt-get install build-essential module-assistant
  6. Run m-a prepare   to configure your system for building kernel modules.  without this the guest additions will fail and ask you to "please install the build and header files for your current kernel"
  7. Now click on install guest additions from the top menu in the sun VirtualBox under Devices.  This should add a new CD Media to your Debian system and a window will open showing all the Guest Additions shell files for different system
  8. If the system did not mount the CD-Rom image for you use this command
    • mount /media/cdrom0
  9. Run the shell file VBoxLinuxAdditions-x86.run to start the installations
  10. Replace the shell file name with the proper file that matches your system
 
 
Enjoy.

User is not in the sudoers file. How to add the user to the sudoers file?

I installed Debian few times on my systems and evey time I start using it I find out that the sudo command does not work with my user account.  I am a big fan of Ubuntu and I am used to it as I used for the last few years and I think the sudo command always worked for me out of the box.  so here is how you get the sudo command to work.
First:  all you need to do is add the following line to the sudoers file in /etc/sudoers
user_name   ALL=(ALL) ALL
Replace user_name with your own user ID
however, you have to use the visudo command to edit the file while being root
so, here is what you need to do:
open a new terminal
switch to root, type "su" then enter the root password
type "visudo" and you will see the sudoers file opened for editting
go to the end of the file and type the line
user_name  ALL=(ALL) ALL
Again, Make sure you replace user_name with your own user ID
then hold the CTRL key and press "o" to save the file and confirm by pressing enter
now hold CTRL key and press "x" to exit the program
type "exit" to exit root mood
then now type sudo gedit and enter your password
if everything went well, you should see the gedit program
you are done,
Enjoy,


Update:  How to add a user to Sudoers account in Ubuntu?
I found out that if you create a new account using "adduser" you do not get the sudoers group by default
so,
  1. Open a terminal using another account such as root or main account
  2. type "sudo nano /etc/sudoers"
  3. Go to the end of the file and type the following
    1. user_name ALL=(ALL)ALL
    2. Replace user_name with your new user name
    3. Save the file and exit "Ctrl x" when asked type y and press Enter to confirm the file name
  4. now log out and login using that user_name and you should have the sudo command working
I tested this process on an embedded Debian system, works great.

Tuesday, June 26, 2012

How to Create or Check the CRC MD5 for a File


Whenever you donwload a file you will need to test the integrity of that file you downloaded

So, you are on the INTERNET and looking for this driver that you need for your new device. Whether you are running MS Windows or Linux you will need to insure that the file you downloaded is the correct file that you are looking for. Here comes the MD5 for the rescue!

So, what is md5 any way?




How you can make use of md5 Tool?




How you can do that in MS Windows?





How about Linux, Ubuntu?

You should be able to run the command, 
md5sum    file_name
you will get something like this



Very simple process, I hope it is useful to someone out there.  You let me know.

Realtek Gigabit Ethernet Not Working with Ubuntu 11.10


New Gigabyte Motherboard Using Ubuntu 11.10 can not use Realtek Gigabyte Ethernet Correctly


Well we need to know/make sure you have the Ethernet card we are talking about.
so, type the following

lspci -nnk | grep -iA2 net

You should get something like this:

elsaghir@elsaghir-Main-Ubuntu:~$ lspci -nnk | grep -iA2 net
06:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller [10ec:8168] (rev 06)
    Subsystem: Giga-byte Technology GA-EP45-DS5 Motherboard [1458:e000]
    Kernel driver in use: r8168

So, now we need to install kernel Headers to be able to build and compile the Ethernet driver
Type:

sudo apt-get install --reinstall linux-headers-generic build-essential dkms
wget http://r8168.googlecode.com/files/r8168-8.025.00.tar.bz2
tar xvf r8168-8.025.00.tar.bz2
cd r8168-8.025.00
sudo modprobe -rf r8169
sudo ./autorun.sh
echo 'blacklist r8169' | sudo tee -a /etc/modprobe.d/blacklist.conf
sudo modprobe -v r8168
sudo depmod -a
sudo update-initramfs -u


now you need to build the driver:
Change folder to where the driver source is   cd r8168-8.026.00/
Build the Driver/Library  sudo make
We need to copy the new Library to the lib folder 
sudo cp src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
Run depmod program to link all modules   sudo depmod -a
Now add the module to the kernel   sudo modprobe -v r8168 
And Update initramfs     sudo update-initramfs -u

if you have your interface in blacklist!  follow these steps:

lspci -nnk | grep -iA2 net
gksu gedit /etc/modprobe.d/blacklist.conf
# blacklist r8169



Update Dec 18, 2011:
At this point I had few update to the kernel, and I noticed every time I have a new one, I lose my network and I have to go through the build again and copy the file to the lib folder,
Of-course that make sense because every time we get a new kernel it is saved in its own folder under
/lib/modules/
so, I created a simple script that will help every time I find my network adapter not functioning correctly after a system update:

cd ~/Downloads/Drivers/r8168-8.026.00/
sudo make
sudo cp src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
sudo depmod -a
sudo modprobe -v r8168
sudo update-initramfs -u

save these instructions to a file, make sure it is executable. and use it when you need to...

Let me know how these notes work for you,...





Links:
http://ubuntuforums.org/showthread.php?t=1865436

Developing GUI Programs with C/C++ in Linux "Introduction"


An introduction to GUI programming using Glade and Code::Blocks

This is an Introduction to my new book I am writing that will introduce GUI development to programmers trying to explore the Linux world and simplify the transformation for MS Visual Studio programmers that need help and direction to a similar environment in Linux world. In this knol, I will publish my first two chapters from my book trying to get more feed back and input on my topics and contents of the book. Also, This will make this knol a Tutorial for this topic. So, it is a work in progress, if you visit and do not see what you were looking for, please, come back a little later or just send me an email and I will gladly discuss your topic or add it to this Knol.


Chapter Index:

Introduction
Chapter 1
Chapter 2
Chapter 3
Chapter4
Chapter5






Introduction:

  • What resources do you need to have to use this book?
  • Why did this book come to life?
  • What do we know about GNU, Open Source?
  • What about Linux Kernel, Distributions?
  • What are the other option to develop GUI programs in Linux?




Programming in Linux is becoming more and more popular as Linux OS gets more user friendly and more regular home users are comfortable using this new Operating System. The more popular Linux Operating System gets the more demanding on adding programs and tools for end user to use. The more demand on programs the more interest in developers to start learning Linux GUI programming. I started learning about Linux about 10 years ago, and at that time it was very interesting new interface, however, it was very hard to understand and find resources to learn more about it. I struggled to learn about it on my own and installed it on an old extra computer I had just to try to keep up with this new environment. At that time I used Mandriva Linux distribution formerly Mandrake Linux. Few years later and I was shocked by how user friendly Linux became and how easy it is to switch to this OS and say good by to other operating systems that we no longer have to use it. As an embedded system programmer and very well oriented with multi programming languages and environment, I wanted to port all my tools and programs to run on Linux the new amazing Operating System so I can really say “I use Linux as my full time OS”.

This book does not teach you how to become a C or C++ programmer, it will introduce C/C++ and make a great use of them but it assumes that you know a good deal of programming concepts and infrastructure. Instead, this book will introduce the GUI programming concept and provide a step-by-step programming examples, to help programmers who are new to Linux or to GUI programming in Linux, take a big jump into GUI programming world and find the resource that will ease developing of new graphical application in Linux OS environment.





What resources do you need to work with this book?

To make a full use of this book you will need to have some resources available. First of all you need a good working computer with no Operating System “OS” to be able to install Linux on it. Or, you could have a computer with a large hard drive and create two partitions one for your original OS and one to install Linux on it. Or you could have your own way of running Linux OS on a computer. For your reference before you start, you probably should keep in mind that working with a compiler and GUI design you will need a fast enough computer with enough resources such as Memory and drive storage. You should also consider a back device like an external USB drive so you can back up your work on it just in case something happens and your computer gets damaged in anyway, even thought that there is a very small chance this could happen but you do not wont to take a chance of loosing your hard work.
Now, let us talk about what minimum resources you should have on your development computer. That is a pentium 4 with a 3GHz processor and at least 1 GB of Memory and lot of storage space. I believe that this spec is not a budget breaker and very easy to come up with. So, after you have this computer you will need to install Linux on it and that brings up a question, what distribution would I need to install? I will immediately answer saying Ubuntu. This is my favorite distribution and that one I used while working on this book. Now, keep in mind that you should download latest release available for Ubuntu. In this book I used Release 9.10 (karmic) which is the latest Ubuntu release at this time, but when you start working you always should download the latest release as there are always a lot of fixes and enhancements every time a new release is available.
Through out this book, I will be using two important GNU programs, Code::Blocks and Glade. These are the two tools you will be using to develop your programs. So, go a head and install them. Next you should know that these two programs require you to have gcc and g++ installed on your computer, the GNU C and C++ compiler and linker. Also, we are going to use the Gtk+ library to build the GUI interface when working with C programming language, and Gtkmm when working with C++ programming language. So, we need to make sure you install all these components on your Ubuntu machine.

Why did this book come to life?

As a long time C/C++ Windows programmer, I am used to find a lot of resources and references when I need help with one of my new topics that I am working on. So, when I started to work on Linux and get used to the GNU gcc and g++ programming environment I found a lot of documentation that are very useful. I also found a lot tools that we can use to develop these type of programs. But, when I started to look at GUI programming, I started to get a lot of dead ends to resources. I placed to questions on the Internet blogs and groups and I got a lot of different answers to what is considered to be the prober way to create a GUI program under Linux. I began to read a lot of documentation and blogs and had to make a decision of what I really want to do. Do I want to use an IDE that would do everything for me? Well, this is not Windows. I really should be aware of every part of my code where I can customise it and change it any time I need to. So, what I really need to do is to understand what is needed to be able to develop a GUI program using C or C++ programming language. So far so good. I continue to read more and found out that to develop a GUI program I need to know what programming language I am going to use. If I am going to use C which requires gcc tool as a compiler and a linker, then I will use Gtk+ which is the library that provides us “programmers”with all the APIs to develop this type of GUI programming. If I am going to use C++ programming language it will require g++ tool as a compiler and a linker, then I will use Gtkmm which is the Gtk+ clone but it is customised for C++ program structures.

Well, as a MS Windows long time programmer, I am really used to the idea of having an IDE, Integrated Development Environment, that will contain and manage all my project structure and configuration. So, I looked around to see what IDEs are available and compared their pros and cons. I found a lot of these IDEs like programs and each one of them had different futures and some limitations. One of the important future I was looking for is the auto-complete of keywords and commands which would really save a lot of time when you are writing a lot of code. Customisation is a nice future that can help when you work a lot with the IDE. Other futures like auto save, text formatter, built-in compile and link tools that internally link to GCC is great options too.


What do we know about GNU, Open Source?

GNU is collection of programs and operating systems that are based on the Free Software idea. GNU was first started by RichardStallman and publicly announced on September 27th , 1983. Software began on January 5th ,1984 after Stallman quit his job so his company would not claim ownership of the free GNU. The plan was to create new free software operating system and bring it to our world just like it used to be in the 1960s and 1970 where programmers were free to study the software they were using, share the software with other people, modify the software to fit their needs, and free to distribute what they modified so others can make use of it.

A lot of people get confused with the idea behind GNU free software and do not exactly understand the meaning of it. The free software term here means free in freedom, freedom to know, freedom to have access to the source code and freedom to change/update that source code to fix or add futures to it. However, this freedom is attached to a responsibility. The responsibility is simply to pass that freedom you have to the users of your applications. So, if you distributing modified programs that are based on GNU programs, then you should give users of your program access to the source code and the freedom to copy, distribute and/or modify it. You should let them know of their rights and present the GNU GPL license to them.

The name GNU was chosen for three reasons. The first reason was it is recursive acronym for “GNU's Not Unix”. So, because GNU is Unix like in design but it is free software and has no Unix code. The second reason is GNU is the real word. It is the name of “Wildebeest”. Third it is an old song , “Song of the GNU” which was a funny song about a talking gnu.

The idea of developing GNU systems is based on the “GNU Project”. The GNU project idea is to deliver free programs to the user and give them the freedom to copy, distribute, and/or modify it. However, without a free operating system, users would still have to use a proprietary software to run their computer. So the main task for the GNU project was to develop a free operating system. The operating system was chosen to be Unix compatible because the design was already proven and portable. And more important compatibility will make it easy for users to switch to the new free OS.

The major components of the GNU are GNU Compiler Collection GCC, the GNU C Library glibc, and more but, these two projects we will use a lot in this book. GCC is the main compiler that we will use to compile the programs we have in this book. There are a lot of other programs developed under GNU GPL license such as email programs, Internet browsers, text formatters, communications tools and utilities, and many other applications.

The GCC or GNU Compile Collections is one of the most important tool in the GNU project. Without the GCC the whole idea of free software would not make any since. With this tool, everyone is able to develop, modify source code and build their executable with out the need to go out and buy an expensive proprietary compiler from a third party source. Even-more, for me to publish this book with all the code I have in it, I would have had to go and find a way to make my reader have access to some type of compiler and linker such as buy a licensed right to distribute a copy of XYZ program with my book that will allow my readers to try out my code and experiment with it. But, thanks to the GNU GCC, all I have to do is point you to the Linux distribution and you have everything you need to create, copy, change and compile all the code in this book. GCC is not just C/C++ compiler and linker, it used for few other programming languages such as C sharp, Java, Ada, Fortran, Pascal, VHDL, and more other languages are supported. Also, gcc can target different processor families such as Alpha, ARM, Atmel AVR, Blackfin, HC12, PowerPC, VAX, x86-64, MIPS, and much more.

What about Linux Kernel?

A year ago, I bought a “Eee pc net-book” to be able to take all my work to any place I go. But, as soon as I powered it up and saw MS Windows XP home edition on it, I said, “Noway that is not what should be running on my net-book” so I immediately repartitioned the hard drive and installed windows XP on a small partition and Ubuntu Linux on the other partition. To be honest, there are still some programs that I might need to run under windows and did not want to force my self with no options if I had to run a windows program or hardware that is not quite supported by Linux.

Well, Linux is a free Operating System that was developed by a Finnish computer science student his name is Linus Torvalds in 1991 and was made free to people to use by 1992. Linus was a student at University of Helsinki and was getting tired of the limitations of the Minix OS, so he decided to develop his own new OS that will be much more stable and free to people to use. He never thought that it will be as popular as it is now. Linux is an open source, it provides anyone with all the source code needed to modify, update, and rebuild the whole OS, so it complies with GNU GPL.

Linux kernel is the operating system that everything else run on top of. Linux kernel is release under the GNU GPL license version 2 plus some proprietary licenses. Most of the Linux kernel has full access to the hardware and has futures to handle interrupts correctly. Also, it improves the support for symmetric multiprocessing (SMP) and preemption which improves latency, and increases responsiveness which simply makes it suitable for real time operating system. When we hear the phrase “Linux distribution” that is not the Linux kernel. Linux distributions are a group of applications tools and utilities that run on top of the Linux Kernel. Such applications are word processors, email program, Internet browser, media players, graphics programs, and communications programs. There are currently over six hundred distributions available and about three hundred of them are in active development. Each distribution was created by a person or group of users. Slackware was created by Patrick Volkerding and then maintained by the Development team. On the other hand, OpenSUSE was created by Novell and started as a business only distribution then changed to focus on the home user desktops and workstations. Below is a list of most popular Linux distributions that I can think of:

Distribution
Creator
Producer
First Public Release
Base Distribution
Latest Release Date
Purpose
UbuntuCanonical Ltd.Canonical Ltd.10/20/04Debian10/29/09General
MandrivaMandrake soft S.A.Mandriva S.A.07/23/98Red Hat Linux04/29/09General
OpenSUSENovell Inc.OpenSUSE Project03/00/1994SUSE Linux11/12/09General
DebianIan MurdockDebian Project08/16/93None09/05/09General
FedoraFedora ProjectFedora Project11/05/03Red Hat Linux11/17/09General
SlackwarePatrick VolkerdingDev Team07/16/93SLS08/26/09General
Gentoo LinuxDaniel RobbinsGentoo Foundation, Inc.03/31/02NoneWeeklyGeneral
Dam Small LinuxJohn AndrewsDev Team2003Knoppix11/17/08Portable
YoperAndreas GiradetThe Yoper Team03/05/03None10/03/07General

Ubuntu:
Ubuntu is free GNU Linux distribution. It started by Mark Shuttleworth and then sponsored by Canonical Ltd. It is the most popular distribution available as it focuses on the ease of use, hardware support and availability of most Linux program packages. Ubuntu is driven from Debian distribution and it is different in the way it has a regular releases every 6 months with long time support (LTS) releases every one and a half years. Also, you can run it off the live-CD with having to install it but when you decide to install it, it is a breath. You can start using it right after the install because it installs most common desktop components. Finally, it has a very strong on-line community for references and support.

Debian:
Debian is also a free GNU Linux Distribution. Is very stable, mature and known to have an outstanding package management. It requires some knowledge to Linux though and is very slow on updates and changes. It is very well maintained and supported by the vast popularity and multilingual community. It is very easy to get help from the Debian related forums and mailing lists.

Slackware:
Slackware is the oldest Distribution to come to life. It was started by Patrick Volkerding on July 13th, 1993 and then maintained by the development team. This distribution is designed for users who like to have control and are not afraid of the command line. One of the disadvantages in this distribution is that the the package system does not have list of dependencies which forces the user to install all package dependencies manually.


Fedora:
Fedora is designed to work with home users, programmers, and corporate servers. In this way it will need some customisations to fit the need of each group of users. Fedora has a great desktop tools and management. It is well known of its new tools and bleeding edge technologies. These advantages bring with some disadvantage which is the instability. So, if you want to use the new futures in Fedora, you will need to realise the consequences.


OpenSUSE:
OpenSUSE one of the top distribution for quite a while as it first appeared around 1992 as S.U.S.E. As a business only distribution and now focuses on home users desktop and workstations. OpenSUSE is managed by Novell, and aims to be the most usable and user friendly desktop Linux distribution. Is is very well known by its great configuration tool, YAST. It has a very well designed control center for administration. Users like it because it is one of the simplest distribution to install and configure. It offers a great support and documentation.

Mandriva:
Mandriva is originally was released to public with the name Mandrake Linux. It became very popular among users who want to switch from MS Windows because of its ease and similarity in desktop layout. Mandriva always up-to-date in tools and software which makes it sometimes unstable.

Gentoo Linux:
Gentoo is really known to be all about customisations. This distribution lets you have the option to customise every and each components of the system. It also has a different type of installation process. It will ask you to choose your kernel, cron and event-logging program. The installation is not click-able and will take a long time and knowledge. If you do not like to read and research then you better choose different distribution with a graphical install.

Dam Small Linux:
dam Small Linux, DSL, is meant to be the smallest Linux distribution ever. You could carry a small basic copy of it with you and boot it from a floppy disk, not that we have these available on most computers any more. But if you have an old computer and wanted to use it for a certain purpose with a small and light Linux distribution, your first choice would be DSL. The ISO is just 50Mb, so you can fit it on a business CD. The real future of DSL that you can boot it directly within other operating system such as MS Windows. So you can take it with you and use it on other computers when you are not home. DSL is based on knoppix which is based on Debian. That makes it have a stable system and good with hardware recognition.

Yoper:
Yoper is know to be the most fastest operating system on earth. It is has something in it that makes it fast and responsive out of the box. Yoper also has a very fast installation, you can install this distribution in about 5 to 10 minutes. The problem with Yoper is that it does not have a lot of configurations. The other problem is Yoper team is very small and lacks manpower. The latest release was in July 2007.


What are the other options to develop GUI programs in Linux?

You can basically write C/C++ programs in Linux using an edit program like gedit in Ubuntu and the GNU gcc, Gtk+, and Gtkmm. However, this is not very convenient when you working on a big project that contains a lot of GUI interfaces and multiple source code files. The idea of using an IDE manager is to mange you file structures and contain everything in one container. Also, all your project settings are stored and managed within a configuration window that is simple to understand and change. Even though, some IDE programs would be so complicated that make finding items and settings very hard and confusing. I find Code::Blocks very simple and complete IDE that you can use now for simple projects and later for advanced projects. Code::Blocks has a simple project manager and still very efficient. The compile and link options are easy to find and configure. Code completion is very helpful. Other programs could be very similar but I found Code::Block easier to adapt after working all these years with MS Visual Studio. Other IDE programs are Anjuta, Qt Creator, Kdevelop, Eclipse, Netbeans.



Web Link:
For more information on GNU visit Wikipedia web site http://en.wikipedia.org/wiki/GNU
GNU General Public License GPL http://www.gnu.org/licenses/gpl.html
Mandriva Linux on Wikipedia http://en.wikipedia.org/wiki/Mandriva_Linux
Wikipedia Linux page http://en.wikipedia.org/wiki/Linux
Linux Distributions Wikipedia http://en.wikipedia.org/wiki/Linux_distribution
Glade User Interface Designer Reference Manual http://library.gnome.org/devel/gladeui/3.6/