Popular Posts

Sunday, May 18, 2008

Thursday, April 17, 2008

Name Mangling

Did you ever hear about Name Mangling? I didn't myself! But it is important to take a look at :)

Sunday, April 13, 2008

Cross Compiling the hard way...

This tutorial contains many hints about cross compiling. You'll never need to understand all this stuff, but it is worth reading anyway! In practice, cross compilers are already built and you'll just use them!
http://www.landley.net/ols/ols2007/tutorial.txt

Predefined Macros in gcc

From the gcc man page:

-dCHARS
CHARS is a sequence of one or more of the following characters, and must not be preceded by a space. Other characters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silently ignored. If you specify characters whose behavior conflicts, the result is undefined.

M Instead of the normal output, generate a list of #define directives for all the macros defined during the execution of the preprocessor, including predefined macros. This gives you a way of finding out what is predefined in your version of the preprocessor. Assuming you have no file foo.h, the command



touch foo.h; cpp -dM foo.h



will show all the predefined macros.

Compiling 32-bit Applications on 64-bit Linux Hosts

You need to install the gcc-mutlilib package. Then:
$ gcc -o hello -m32 hello.c

the -m32 flag tells the compiler to target the 32-bit architecture instead of the 64-bit architecture

Also, you may need to take a look at this looooooong discussion:
http://ubuntuforums.org/showthread.php?t=24575

For kernel compiling, you will need to explicitly specify the architecture:

$ make ARCH=i386 menuconfig

$ make ARCH=i386 bzImage

Happy compiling :)

*** Returning to this issue with Makefiles

just run:

$make CFLAGS=-m32 LDFLAGS=-m32

this adds the -m32 option to both the compiler flags and the linker flags

Saturday, April 5, 2008

PDF Multiple Page Per Sheet in Linux

To print multiple pages/sheet, you'll need the `pdfjam' package installed. Then,

$pdfnup --nup 1x2 input.pdf

Friday, March 14, 2008

Open Source Alternative to Commercial Software

http://downloadpedia.org/Open_Source_Alternative_to_Commercial_Software

My Ubuntu Sytem borke :(

I spent a scary night yesterday trying to fix my Ubuntu installation. I was a victim for the bug related to libc6. The problem is that after updating the system, the new libc6 package was broken and it rendered the system in a total mess :((

Almost every single application is depending on the standard C library (glibc/libc6/GNU C Library). The fact that the libc6 is not functioning means the system is now totally unstable! Error message of the sort 'null pointer reference' began to show everywhere. I can't start any kind of terminal. Even logging into the Virtual Consoles failed and just thrown some 0x777FFD... addresses on me. I had no access to any package manager and I cannot undo the buggy installation. Even starting a browser to search for the problem failed! I had no other option but to restart and login using a liveCD.

After a lot of searching for the problem, I came across this bug description.
I have learnt a lot :)

To break the normal boot process you need to boot with the kernel option:
break=bottom

This puts you into the initial ram filesystem prompt (initramfs) just before starting the init-bottom scripts

To unpack a .deb archive:
ar -x *.deb

This leaves you with two tarball control.tar.gz and data.tar.gz. I used this to unpack the libc6 deb archive by hand and copy the necessary data.tar.gz files into their correct locations; thus replacing the buggy libc6 installation with a correct installation.

When you 'chroot' into your Ubuntu installation and get the message: 'Unable to execute /bin/bash: Permission Denied'. And even 'chroot /path/to/your/rfs /usr/sbin/apt-get' fails for the same reason. Then most probably the 'ld*' files in /lib/ and /sbin/ldconfig are not give the execute permission.
'chmod +x /lib/ld*' and 'chmod +x /sbin/ldconfig' corrected the problem.

Notice that ld* is the dynamic link loader and is needed by almost every executable file in your system. Also, 'ldconfig' is needed by dpkg, apt, aptitude and all package managers to be able to process your packaging system.

Wednesday, February 27, 2008

Probability ABC

Nice Quote from:
http://blogs.jhu.edu/sukye/2008/probability-abc/

``A priori probability is the probability estimate prior to receiving new information.

Posterior probability is a revised probability that takes into account new available information. For example, let there be two urns, urn A having 5 black balls and 10 red balls and urn B having 10 black balls and 5 red balls. Now if an urn is selected at random, the probability that urn A is chosen is 0.5. This is the a priori probability. If we are given an additional piece of information that a ball was drawn at random from the selected urn, and that ball was black, what is the probability that the chosen urn is urn A? Posterior probability takes into account this additional information and revises the probability downward from 0.5 to 0.333 according to Bayes’ theorem, because a black ball is more probable from urn B than urn A.

Bayes’ Theorem:
Bayes theorem is a formula for revising a priori probabilities after receiving new information. The revised probabilities are called posterior probabilities. For example, consider the probability that you will develop a specific cancer in the next year. An estimate of this probability based on general population data would be a prior estimate; a revised (posterior) estimate would be based on both on the population data and the results of a specific test for cancer.
The best way to understand the terms is to look at an example. Consider a screening test for intestinal tumors. Let Ai = A1 = the event “tumor present”, “B” the event “screening test positive” and “A2″ the event “tumor not present” with no further A’s.
If you have a tumor, the screening test has an 85% chance of catching it — P(B|A1) = .85. However, it also has a 10% chance of falsely indicating “tumor present” when there is no tumor P(B|A2) = .10. The probability of a person having a tumor is .02 P(A1) = .02.
If the screening test is positive, what is the probability that you have a tumor?
.02*.85/(.02*.85+.98*.10)
= .017/(.017+ .098)
= .148''

Sunday, August 19, 2007