WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Gcc C compiling and linking for older kernel  (Read 1859 times)

Offline settimid

  • Newbie
  • *
  • Posts: 8
Gcc C compiling and linking for older kernel
« on: June 05, 2023, 03:36:13 AM »
Hi all!
I’m trying to set up an OpenSuse 15.4 (x64) as a cross-compiling machine for a C project.
Target(s) are tinycore, multiple versions: x86 and x64 from 3.8.4 to newest ones.

I managed to compile and run both 32bit and 64bit, static linked binary on the OpenSuse.
Runs smoothly on newer TC, but when I go to run the binary on the target machine with older tinycore 3.8 i get an error: FATAL: kernel too old

From what I understand the problem is that the glibc distributed with OpenSuse are too new, and are not compatible with the 2.6.33 kernel of the target system.
Does anyone know how to compile a binary that is compatible with an older kernel on OpenSuse? Can you point me in the right direction?

It's my first time with tc, I already find myself doing complicated things!

D.

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Gcc C compiling and linking for older kernel
« Reply #1 on: June 05, 2023, 03:44:25 AM »
For who reads: there are more than one reason why I prefer to have a single recent Suse and cross-compile instead of multiple VMs, so at the moment I rule out the possibility of having several VMs to be able to compile with various kernels/glibc.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: Gcc C compiling and linking for older kernel
« Reply #2 on: June 05, 2023, 03:45:39 AM »
There is a configure switch “—enable-kernel=“ for glibc where you set the minimum kernel version to work with - I guess you will have to recompile glibc and set the appropriate kernel version.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: Gcc C compiling and linking for older kernel
« Reply #3 on: June 05, 2023, 11:31:35 AM »
Replacing glibc on a big binary distro is usually trouble, the easiest path is for your host to have the oldest glibc you target.
The only barriers that can stop you are the ones you create yourself.

Offline settimid

  • Newbie
  • *
  • Posts: 8
Re: Gcc C compiling and linking for older kernel
« Reply #4 on: June 06, 2023, 04:27:32 AM »
> Replacing glibc on a big binary distro is usually trouble

Yes, I've read this warn several times, and the route of re-compiling glibc on my build system doesn't seem the easiest!

>  the easiest path is for your host to have the oldest glibc you target.

A simply quick and dirty copy of /usr/lib/ folder from target, to /usr/lib-old/ of host build system, and my makefile pointing /usr/lib-old/libc.a etc etc when linking could be enough? If so, I'm very happy.
« Last Edit: June 06, 2023, 04:34:13 AM by settimid »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: Gcc C compiling and linking for older kernel
« Reply #5 on: June 06, 2023, 10:27:28 AM »
Yes, copying the old libc like that could work, though I meant using an older distro.
The only barriers that can stop you are the ones you create yourself.