>> DB> I want to build linux binaries from sources with gcc under FreeBSD.
>> DB> AFAIK, there are two solutions to solve this problem:
>> DB> 1) doing some kind of cross compilation with native gcc under FreeBSD
>> I'm not sure if this is easily achievable, since compilation is only one
>> step when building a binary. Linking is another issue. Linuces are
>> usually based on glibc, *BSDs not.
>> DB> 2) installing linux gcc (with linux emulation) under FreeBSD
>> Does this make any difference from using a "native" compiler? This does
>> not solve the linking problem. And unless you build statically linked
>> binaries, you still have trouble with supporting various distro's based
>> on different glibc versions. It's probably not worth the hassle...
>> BTW: Is ELF the same on BSD and Linux?
AFAIK, in there lies most of the problems involved: ELF is exactly the same
for Linux and FreeBSD binaries, and it was not originaly designed to support
more then one "subsystem" or ABI on a single OS. There is some special magic
involved in recognizing which type (FreeBSD or Linux) the executable is. So,
it would be very confusing for compiler & linker to understand the subtle
differences. I am not an expert, but IMO if you must build Linux executables
under FreeBSD, you sould use the whole Linux toolchain (compiler, linker &
libraries) running under Linux emulation. Even so, you will probably have to
fiddle with separating the FreeBSD environment (includes, libraries) from
the Linux one while building.
(I myself would like to know more about this subject, so if anybody has more
insight, please follow up on this).
--
--
Do not meddle in the affairs of sysadmins, for they can make your life
miserable by doing nothing.