how to compiler c cdoe, let the bin file Cross linux Platform - Linux

This is a discussion on how to compiler c cdoe, let the bin file Cross linux Platform - Linux ; hi all i develope one simple program in linux Platform. you know ,there are a lot of linux, suse centos,redhat,debian, so if i use gcc -o hello xxxx.c ,i got the bin file. i can run it under my develop ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: how to compiler c cdoe, let the bin file Cross linux Platform

  1. how to compiler c cdoe, let the bin file Cross linux Platform

    hi all
    i develope one simple program in linux Platform. you know ,there
    are a lot of linux, suse centos,redhat,debian, so if i use gcc -o
    hello xxxx.c ,i got the bin file. i can run it under my
    develop system(suse 9.0). but it will fail in the other linux,
    (centos). different libc version

    but i found the sun 's jre . it's a bin file, but it can run under
    the suse ,centos, redhat ... very well. so i think how it make this?.
    how to compiler c code, let the bin file cross linux platform
    like centos debian suse. thanks

    best regards!

    papaya

  2. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    > * *but i found *the sun 's jre . it's a bin file, but it can run under
    > the suse ,centos, redhat ... very well. *so i think how it make this?.
    > how to compiler c code, let the bin file cross linux platform
    > like centos debian suse. *thanks
    >


    Are you thinking about the actual JRE executable or are you thinking
    about a compiled Java program?

    f you are wondering how a compiled Java program runs on various
    distributions of linux, then you are thinking about the Java Virtual
    Machine. Which is a whole other subject.

    If you are thinking about the actual JRE executable, or any executable
    for that matter, they have all been configured and compiled for that
    particular linux distro and platform. You dont really compile once run
    anywhere with linux, you usually configure then build from source.
    With modern distributions they do this for you via packages. If you
    really want to develop cross-distribution code, Look into autoconf and
    automake.

  3. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    flywav wrote:
    > hi all
    > i develope one simple program in linux Platform. you know ,there
    > are a lot of linux, suse centos,redhat,debian, so if i use gcc -o
    > hello xxxx.c ,i got the bin file. i can run it under my
    > develop system(suse 9.0). but it will fail in the other linux,
    > (centos). different libc version
    >
    > but i found the sun 's jre . it's a bin file, but it can run under
    > the suse ,centos, redhat ... very well. so i think how it make this?.
    > how to compiler c code, let the bin file cross linux platform
    > like centos debian suse. thanks


    In general, programs linked against a given version of libc will
    continue to work with newer versions. So look for the distro with
    the oldest libc you want to support (within reason) and build on that.
    Then your binary will work on most distros with same or newer libc.
    Be mindful of other libs you may be linking with too.

  4. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    maddenpj@gmail.com wrote:

    > If you are thinking about the actual JRE executable, or any executable
    > for that matter, they have all been configured and compiled for that
    > particular linux distro and platform. You dont really compile once run
    > anywhere with linux, you usually configure then build from source.


    I think he means that some downloaded .bin files run independently of
    the distribution, and he wants to build one of those.

    (I think the JRE executable does this, and so do some game installers.)

    Mark.

    --
    Mark Hobley,
    393 Quinton Road West,
    Quinton, BIRMINGHAM.
    B32 1QE.

  5. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    On Aug 5, 9:14*pm, flywav wrote:
    > hi all
    > * *i develope one simple program in linux Platform. you know ,there
    > are a lot of linux, *suse centos,redhat,debian, * so if i use gcc -o
    > hello *xxxx.c ,i got the bin file. i can run it under my
    > develop system(suse 9.0). but it will fail in the other linux,
    > (centos). different libc version
    >
    > * *but i found *the sun 's jre . it's a bin file, but it can run under
    > the suse ,centos, redhat ... very well. *so i think how it make this?.
    > how to compiler c code, let the bin file cross linux platform
    > like centos debian suse. *thanks


    Link you program with static library so that it has little dependency
    on the system libraries.

  6. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    On Aug 5, 7:36*pm, Bin Chen wrote:

    > Link you program with static library so that it has little dependency
    > on the system libraries.


    This is a mixed bag. For some programs this helps, for others, it
    hurts.

    For example, if you don't link dynamically to the resolver libraries,
    you cannot resolve the way that system wants you to. But if you do
    link dynamically to the resolver libraries but statically to libc,
    things will break horribly if you get a code path that 'malloc's
    something in the resolver (calling into the libc it's linked to) and
    'free's it in your application (calling into the libc you are linked
    to).

    It's very tricky to link statically to some libraries and dynamically
    to others when both sets of libraries include calls into libc. And
    it's almost impossible to do everything statically (the resolver, PAM,
    and many other things almost have to be dynamic).

    Having more than one libc can be harmful to your health.

    DS

  7. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    On 2008-08-05, flywav wrote:
    > hi all
    > i develope one simple program in linux Platform. you know ,there
    > are a lot of linux, suse centos,redhat,debian, so if i use gcc -o
    > hello xxxx.c ,i got the bin file. i can run it under my
    > develop system(suse 9.0). but it will fail in the other linux,
    > (centos). different libc version
    >
    > but i found the sun 's jre . it's a bin file, but it can run under
    > the suse ,centos, redhat ... very well. so i think how it make this?.


    How it's done is static linking. that means the used parts of libc are
    built-into the binary at compile time instead of being loaded immediately
    before execution.

    Then it will run on any linux with a compatible kernel version.
    (for most things only the major number is significant)

    but you still can't run X64 code on a X86 kernal, or PPC code
    on an ARM processor

    statically linking against (L)GPL libraries has legal ramifications you
    should check if you don't inted to release the source of your program.

    Bye.
    Jasen

  8. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    "flywav" wrote in message
    news:17fa65b3-a81f-48c4-aba7-a9a1bdfa8e59@w24g2000prd.googlegroups.com...

    > i develope one simple program in linux Platform. you know ,there
    > are a lot of linux, suse centos,redhat,debian, so if i use gcc -o
    > hello xxxx.c ,i got the bin file. i can run it under my
    > develop system(suse 9.0). but it will fail in the other linux,
    > (centos). different libc version
    >
    > but i found the sun 's jre . it's a bin file, but it can run under
    > the suse ,centos, redhat ... very well. so i think how it make this?.
    > how to compiler c code, let the bin file cross linux platform
    > like centos debian suse. thanks


    There is no single and complete answer to this. It's worth having a look
    at the Linux Standard Base ("LSB") compatibility system, which works
    for a lot of Linuxes, but not all of them. It also only handles a limited
    range of system libraries.

    Start at http://www.linuxfoundation.org/en/LSB and read about the
    LSB SDK, to see if you can fit within its limitations.

    John






  9. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    Mark Hobley wrote:
    > maddenpj@gmail.com wrote:
    >
    >> If you are thinking about the actual JRE executable, or any executable
    >> for that matter, they have all been configured and compiled for that
    >> particular linux distro and platform. You dont really compile once run
    >> anywhere with linux, you usually configure then build from source.

    >
    > I think he means that some downloaded .bin files run independently of
    > the distribution, and he wants to build one of those.
    >
    > (I think the JRE executable does this, and so do some game installers.)


    I think he built a program he wrote but it only ran on his system
    But the JRE will run on other distributions.

    The secret is to compile statically, rather than build against shared
    libraries.
    --
    | spike1@freenet.co.uk | |
    | Andrew Halliwell BSc | "The day Microsoft makes something that doesn't |
    | in | suck is probably the day they start making |
    | Computer science | vacuum cleaners" - Ernst Jan Plugge |

  10. Re: how to compiler c cdoe, let the bin file Cross linux Platform

    Joe Beanfish wrote:
    > flywav wrote:
    >> hi all
    >> i develope one simple program in linux Platform. you know ,there
    >> are a lot of linux, suse centos,redhat,debian, so if i use gcc -o
    >> hello xxxx.c ,i got the bin file. i can run it under my
    >> develop system(suse 9.0). but it will fail in the other linux,
    >> (centos). different libc version
    >>
    >> but i found the sun 's jre . it's a bin file, but it can run under
    >> the suse ,centos, redhat ... very well. so i think how it make this?.
    >> how to compiler c code, let the bin file cross linux platform
    >> like centos debian suse. thanks

    >
    > In general, programs linked against a given version of libc will
    > continue to work with newer versions. So look for the distro with
    > the oldest libc you want to support (within reason) and build on that.


    As long as they're the same MAJOR version, y'mean.
    Remember when libc5 became libc6? major breakage if you wanted your old
    progs to run. You needed to keep both versions of the libraries on your
    system to maintain compatibility.
    --
    | spike1@freenet.co.uk | Windows95 (noun): 32 bit extensions and a |
    | | graphical shell for a 16 bit patch to an 8 bit |
    | Andrew Halliwell BSc | operating system originally coded for a 4 bit |
    | in |microprocessor, written by a 2 bit company, that|
    | Computer Science | can't stand 1 bit of competition. |

+ Reply to Thread