Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
I write some programs on linux with C I want to run these programs on many remote computers, which are installed with fedora or ubuntu I compiled the program with ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    87

    how to make excutable files based on source codes


    I write some programs on linux with C I want to run these programs on many remote computers, which are installed with fedora or ubuntu

    I compiled the program with gcc on local machine, however the excutable file is not workable on remote machines.

    for example: I use

    gcc -o udp_server udp_server.c

    on local machine to get a excutable binary file udp_server and then I copy it to a remote machine and run it there, the error is:

    -bash: ./udp_server: /lib64/ld-linux-x86-64.so.2: bad ELF interpreter: No such file or directory

    the local machine: fedora Fedora release 16 (Verne) Kernel \r on an \m (\l) 3.6.10-2.fc16.x86_64 GNU/Linux

    the remote machine: Fedora release 12 (Constantine) Kernel \r on an \m (\l) 2.6.32-36.onelab.x86_64 GNU/Linux

    on these remote machines, there are no gcc compiler so I hope I can make some excutable files so that they can be executed on those remote machines

    so what kind of excutable files should I make, and how to make them? any recommenation tools or procedures? thanks!

  2. #2
    Just Joined!
    Join Date
    Sep 2012
    Location
    Nashville, TN
    Posts
    98
    Looks like your problem could be that you are missing the elfutils. do a search for elfutils by going to the terminal and typing
    Code:
    yum search elfutils
    This should list the package that can be installed. (Sorry I don't have my fedora machine in front of me or I could get you the exact package name to install)

  3. #3
    Just Joined!
    Join Date
    May 2012
    Posts
    87
    the machine is a x86_64 machine
    Code:
    [kk@openlab1 ~]$ uname -or
    2.6.32-36.onelab.x86_64 GNU/Linux
    but the results are for 32 bits machines, what is wrong?

    Code:
    [kk@openlab1 ~]$ yum search elfutils
    fedora/metalink                                          | 3.3 kB     00:00     
    fedora                                                   | 4.2 kB     00:00     
    fedora/primary_db                                        | 9.7 MB     00:04     
    updates/metalink                                         | 3.1 kB     00:00     
    updates                                                  | 4.7 kB     00:00     
    updates/primary_db                                       | 5.1 MB     00:02     
    updates/pkgtags                                          |  85 kB     00:00     
    ============================== Matched: elfutils ===============================
    elfutils.i686 : A collection of utilities and DSOs to handle compiled objects
    elfutils-devel.i686 : Development libraries to handle compiled objects
    elfutils-devel-static.i686 : Static archives to handle compiled objects
    elfutils-libelf.i686 : Library to read and write ELF files
    elfutils-libelf-devel.i686 : Development support for libelf
    elfutils-libelf-devel-static.i686 : Static archive of libelf
    elfutils-libs.i686 : Libraries to handle compiled objects

    Quote Originally Posted by bsdtux View Post
    Looks like your problem could be that you are missing the elfutils. do a search for elfutils by going to the terminal and typing
    Code:
    yum search elfutils
    This should list the package that can be installed. (Sorry I don't have my fedora machine in front of me or I could get you the exact package name to install)

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2012
    Posts
    87
    besides, I need a universal solution, not specific. is it possible to include the library in the excutable files so that I don't need to do specific work on different machines?

  6. #5
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,439
    You can statically link all needed libraries into your binary.
    This will ensure that your program will run on most -if not all- machines of the same architecture (arm, x86, etc).

    However:
    - Your program will need more ram, as the libs are now part of it. Which might be an issue for embedded systems or if your program is started multiple times at once.
    - You will have to take maintenance of the statically linked libraries, as they can no longer be updated by the system´s package manager.
    - Related to the previous point: Security maintenance of the statically linked is now also your job

    The above points may be void, if this is for your personal use and machines.
    But in or for a company/organization I suggest to give them some thought.
    Or the next security audit or grumpy sysadmin (like me ) might flat out reject your program.
    A updated system is an essential part of good maintenance, and statically linked programs tend to undermine this.


    The clean approach would be to build native packages -containing the dynamically linked version of your program- for each supported distribution.
    Btw, this is a criteria which neither fedora 12 nor 16 fullfill: Fedora (operating system) - Wikipedia, the free encyclopedia

    The general workflow is:
    - have a buildmachine for every supported distro: e.g. fedora 18
    - create a specfile for your program
    - with every new release (not commit): build a rpm per supported distro
    - make the rpms available via a repository
    - update all the machines with the new version

    This workflow can be mostly automated.

    The advantages vs static linking are
    - You only have to take are about your code and program. The libs are covered by system package
    - Your program is managed by the standard package manager
    - Which also solves the distribution problem by a standard mechnism (repo)
    Last edited by Irithori; 03-09-2013 at 11:32 AM.
    You must always face the curtain with a bow.

  7. #6
    Just Joined!
    Join Date
    May 2012
    Posts
    87
    Thanks, I just want to do some experiment with my program on different machines, so it is not for organization or commercial use
    static solution is better!
    are there any good articles about static solution?

  8. #7
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,439
    This page might be a starting point
    Link Options - Using the GNU Compiler Collection (GCC)
    You must always face the curtain with a bow.

  9. #8
    Just Joined!
    Join Date
    May 2012
    Posts
    87
    if my current machine is with fedora
    the remote machine is with ubuntu
    they are all with 86x84

    I use static linking on my fedora machine to make an excutable
    then is the excutable workable on the remote ubuntu machine or not?
    if not , what can I do?

    Quote Originally Posted by Irithori View Post
    This page might be a starting point
    Link Options - Using the GNU Compiler Collection (GCC)

  10. #9
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,439
    It should work.
    But you need to test on all your platforms anyway to be sure.

    And again, static linking is seen as cheap and sloppy (at least by me and all infosec guys I know).
    Once you leave the experimentation stage, consider going the package route.
    Or just release the source and let someone take over package management.
    You must always face the curtain with a bow.

  11. #10
    Just Joined!
    Join Date
    May 2012
    Posts
    87
    Quote Originally Posted by Irithori View Post
    It should work.
    But you need to test on all your platforms anyway to be sure.

    And again, static linking is seen as cheap and sloppy (at least by me and all infosec guys I know).
    Once you leave the experimentation stage, consider going the package route.
    Or just release the source and let someone take over package management.

    OK, thanks
    sorry, just one final question
    if the remote machine is i686 with ubuntu
    but my machine is x86_64 with fedora
    how to make an excutable on my machine so that it can work in the ubuntu machine with i686

    thanks!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •