Popular Posts

Sunday, June 29, 2008

Compiling over NFS

Ever needed to compile over exported NFS system in Linux. I needed it to compile some programs on my PC using a compiler in a virtual box ;-)

On the NFS server

add the following line to /etc/exports (Debian/Ubuntu systems)

/path/to/exported/directory *(rw,no_subtree_check,insecure,no_root_squash)



On the client machine (the one that will compile)

add the following line to /etc/fstab

10.0.2.2:/path/to/exported/directory /path/to/mnt/point nfs user,rw,exec 0 0


Note: replace 10.0.2.2 with the server IP or hostname

Warning: this setup is TOTALLY INSECURE!!

but who cares ;-)

Tuesday, June 17, 2008

What is linux-gate.so.1?

Check this excellent article by Johan Petersson. Be sure to equip yourself with good knowledge about ABIs before reading!!

http://www.trilithium.com/johan/2005/08/linux-gate/

Thursday, June 12, 2008

BUG! -- the Biomedical Unix Geeks club

Biomedical Engineering make extensive use of software. Signal processing algorithms and other aspects of the biomedical engineering needs extensive study of computer science and software engineering. Unix platform is of special importance in the medical field due to its stability and ubiquity.
This club is for all biomedical engineers who love Unix, Software Engineering and Computer Science.

IMHO, Unix provides the best environment for the study of algorithms and computer science. The Unix tools and development also implements important point of the software engineering. Hence, came the idea of this club.

Please share your ideas with me on how this should go!

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.