Friday, January 04, 2008

More Linux Frustrations

As stated in my previous post, I've managed to load Ubuntu Linux (my version of Ubuntu is a GUI over a Gnome Linux kernel), dual-boot my computer between Linux and WinXP, and start some very basic programming.

Er, I may have left out that last part about the programming.

I used Synaptic Package Manager to load the Gnu C Compiler (gcc) into Ubuntu. I even managed to get the basic "Hello, world!" program made and compiled. And that's when the frustrations started.

I went a step beyond the "Hello, world!" by writing a really small program that would calculate and display the value of sin(1). That's it. Nothing fancy. Just wanted to see how the output would look. How many digits it would display.

Here's the program:

#include
#include

main()

{

double x;

x = sin(1);

printf("%f", x);

}


As I said, absolutely nothing fancy. I could have probably made it simpler, but this was simple enough. Then, I compiled it with the following command:

gcc complex.c -o complex

and got the following message:

/tmp/ccNjXwiK.o: In function `main':
complex.c:(.text+0x17): undefined reference to `sin'
collect2: ld returned 1 exit status

Those of you who are used to programming in Linux have seen the error. I did not include a link to the math libraries, meaning I didn't add the "-lm" switch with the command. Hence, my command should have been:

gcc complex.c -o complex -lm

That little switch tells the compiler to link to the math library.

Here's my obviously really stupid question: WHY do I have to link to the math library when I have #include math.h in the header of the program? When I compiled this exact same program in my Windows box, I received absolutely no errors with the following command:

cl complex.c

See how simple that was? Just typed in the command for the compiler, and it compiled. Wow! What a thought? Who would have thunk it?

Instead, I have to manually put in a switch telling the compiler to load the math library. When I have math.h in the header.

Yeah, Linux is so much better than Windows.

Tuesday, January 01, 2008

Its the New Year... And Now For Something Completely the Same

This will be a working log of my efforts to:

a) take a computer currently loaded with Windows XP Home edition,
b) re-partition the hard drive,
c) install Ubuntu Linux onto one of the new partitions,
d) install Windows 98 onto the remaining partition,
e) create a multi-boot system and
f) use the Ubuntu Linux system, along with Gnu C Compiler (GCC) to learn C programming.

To start, the system in question is a re-built Dell Dimension 4600. It currently holds 512 MB RAM, a 160 GB hard drive, and two generic CD-ROMs.

I'm initially going to try to use Symantec's Partition Magic 8.0 to re-partition the hard drive.

UPDATE: Using Partition Magic 8.0, I was able to re-partition the 160 GB hard drive into four logical drives. They are a 120 GB drive (C:, for Windows XP), a 20 GB, a 1.5 GB, and a 10 GB. These are all approximate sizes. But, combined, they take up all of the hard drives physical space. I formatted the 20 GB and the 10 GB drives as EXT3, the current standard Linux format. The third I created as a Linux SWAP drive. To go a bit more in-depth, I partitioned the hard drive between the primary (C:, where WinXP resides) and an extended. From the extended, I created the other three logical drives.

My next step was to install Ubuntu. I started with an Ubuntu 6 (6.10) CD. I placed it in the drive, re-started the computer, and then ensured that the computer booted from the CD-ROM. It did, and I was brought up in a standard Ubuntu Linux desktop graphical environment. One of the icons stated "Install Ubuntu". I double-clicked that icon. In short order, I was asked to provide my name, a name for my user account, and a password. I was also asked to confirm the date and time. The next screens were the important ones.

At one point during the install, I was brought to the screen where I have to select an option to partition the hard drive. Apparently, the Partition Magic didn't do everything that Ubuntu wanted in order to install the OS. The first screen provided three options:
  • Resize the primary partition (hda1) & use the freed space.
  • Erase the entire disk (NOTE: Self-defeating. Not an option.)
  • Manually edit the partition table.
I selected the third option to manually edit the partition table. I set the 20 GB partition as the root ("/") drive, the 10 GB partition as the media drive, and the 1.5 GB drive as the swap drive. I made sure that all other drives were removed (select the blank option at each menu), and checked "reformat drive" next to the three Linux drives. I then clicked on "Next". The screen that came up said that it was ready to install Ubuntu and it would install "Grub" on "hd0". Grub is the program used to select the particular OS in a multi-boot environment. I clicked on "Install". Ubuntu required ~20 minutes to install the Linux OS.

After install, the system re-started and the Grub program kicked in. The menu that came up had three options for Ubuntu (normal mode, safe mode, and a memory test) and one for Windows XP. I selected the normal mode (which was highlighted by default), and Ubuntu came up properly. Ubuntu popped up a window telling me to download certain updates. I did so, which took some time. There were 217 updates! After that, Ubuntu re-started. This time, Grub had 5 options for Ubuntu (6.10, 6.12) and one for WinXP. I selected the top one (highlighted by default) and came up in the Ubuntu environment. I then upgraded Ubuntu to the latest version (7.04). Again, after re-starting, there were now 7 options for Ubuntu (6.10, 6.12, and 7.04) in Grub. Selected the default entry for Ubuntu 7.04 and entered the Ubuntu environment.

Once it finished loading, I started up Firefox and web surfed. Everything worked properly.

I re-started the computer and selected Windows XP. WinXP also came up properly. However, Skypemate and Norton Anti-Virus no longer have icons in the system tray. This probably has nothing to do with the partitioning of the hard drive. The last thing I did in WinXP was to load both some Windows updates and some Norton updates. Most likely, these created some hiccup in the system.

Re-booted back into Ubuntu. I've noticed that Ubuntu comes up much faster than previously when I'd loaded it onto a different computer.

Started Synaptic (System -> Administration -> Synaptic Package Manager). Discovered that the GNU C Compiler is already installed. I know this because I checked under "Development" and "gcc" (which stands for GNU C Compiler) was already checked. I opened a command terminal and typed "gcc". When I hit enter, it replied, "gcc: no input files". It appears to be working.

I've now re-partitioned the hard drive (step (b) is complete), installed Ubuntu Linux on the other partition (step (c) is complete), created a multi-boot system (step (e) is partially complete) and GCC is loaded onto the Linux system (I'm ready for step (f)).