Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am an old newbie I am learning now a Operating Systems course where we need to compile a program in 9.10 Ubuntu. this program is not running as expected on further releases of Ubuntu (such as 12.04) my question is how to compile a c program using the kernel of 9.10 from Ubuntu 12.04 (the newest release) remarks : 1 Ive installed an Ubuntu 9.10 partition on my computer. so I can use the libraries from there. but, nevertheless, I would like to work from my 12.04 partition. 2 maybe this manual could help

thanks niv

share|improve this question
add comment

1 Answer

You'd be best off creating a "chroot" for Ubuntu 9.10, and compiling within that chroot.

There's some detail about this in my answer to Building multiple packages for deployment on different Ubuntu versions, but the basic procedure is:

  • Use mk-sbuild --name=my-karmic-chroot karmic to create a new chroot for Ubuntu 9.10 (the codename for 9.10 is "karmic")
  • Use schroot -c my-karmic-chroot to enter the new chroot, and do your compiling

If you're compiling Ubuntu packages, the sbuild tool can be used to automate this.

Note that this does not use the kernel of 9.10, only the userspace components (including libc and C runtime libraries). You'll still be running the 12.04 kernel. However, do you specifically need the 9.10 kernel?

If you really do need the 9.10 kernel, you can use virt-manager to setup a 9.10 virtual machine on your 12.04 install. You can then log into this like it's a real 9.10 machine.

share|improve this answer
    
thanks for the answer –  jokop Mar 13 '12 at 11:35
    
but I will like to follow the instructions found in the link Ive shown earlier. even simpler, I can replace the gcc option -nostdinc explained in the link with --sysroot=my_ubuntu_9.10_partition then I hope it would compile with the 9.10 glibc libraries\includes –  jokop Mar 14 '12 at 9:43
    
You could do that, but a chroot is "cleaner"; for more complex projects, there may be other system dependencies that aren't controlled by gcc's sysroot configuration. eg, stuff that uses pkg-config. –  Jeremy Kerr Mar 14 '12 at 9:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.