Results 1 to 5 of 5

Thread: Can not execute binary file in ubuntu 12.04

  1. #1
    Join Date
    Feb 2014
    Beans
    2

    Can not execute binary file in ubuntu 12.04

    Hello everyone,

    I am a new user at ubuntu and I'm programming c in that platform.

    Now I tried two ways to work, on the simple document writer and in Eclipse.

    I both ways when I try to run a program on the terminal I get the following message:
    Code:
    bash: ./myprog: cannot execute binary file
    Where myprog is a compiled c program with this code:
    Code:
    gcc -ansi -Wall -c first.c -o myprog
    My system is windows 8.1 with 64bit.
    Please note that I have had a 64bit OS on my previous laptop and I managed to run files in that ubuntu system with no problems, so I don't think it's a 64-bit 32-bit kind of problem.
    It doesn't matter if I write the code on eclipse or in the document writer, everytime I try to run my file I get the same error.

    Please, your help is highly appriciated, thank you!
    Last edited by assaf2; February 22nd, 2014 at 01:21 PM.

  2. #2
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,821
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Can not executre binary file in ubuntu 12.04

    So, do you use Windows 8 or Ubuntu 12.04? Programs compiled on Windows won't run on Ubuntu, and vice versa. Running your programs in Ubuntu from a Windows partition won't work either, but that gives you a "permission denied" error, instead of the "cannot execute binary file" error.

  3. #3
    Join Date
    Feb 2014
    Beans
    2

    Re: Can not executre binary file in ubuntu 12.04

    Oh I am sorry for not clearing this out - I am running ubuntu 12.04 on VMWARE as a terminal on windows 8.1 64 BIT.

  4. #4
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Can not executre binary file in ubuntu 12.04

    Drop the -c flag - it stops compilation short (at the object file stage) rather than linking with the standard libraries necessary to create an actual executable

    Code:
    gcc -ansi -Wall first.c -o myprog
    From man gcc
    Code:
           -c  Compile or assemble the source files, but do not link.  The linking
               stage simply is not done.  The ultimate output is in the form of an
               object file for each source file.

  5. #5
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,821
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Can not execute binary file in ubuntu 12.04

    Good catch, I missed the -c option. That must be it.

Tags for this Thread

Bookmarks

Posting Permissions

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