Results 1 to 3 of 3

Thread: "cannot execute binary file"

  1. #1
    Join Date
    Nov 2005
    Location
    Sweden
    Beans
    257
    Distro
    Kubuntu 9.10 Karmic Koala

    "cannot execute binary file"

    Hi all! A long time ago I made a few simple hello world apps in c++ but nothing fancy. Now I've been to java classes for a while and thought I would try some more c++ however I can't run even the simplest hello world applications!

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
      cin.get();
    
      return 1;
    }
    The code is taken from http://www.cprogramming.com/tutorial/lesson1.html. I compile this using "g++ -c hello.cpp -o output" and it works fine but when I try to run it, just doing "./output" it just wont start! All I get is
    Code:
    bash: ./output: cannot execute binary file
    What does this mean? I just don't get it, am I not compiling it right?

  2. #2
    Join Date
    Oct 2006
    Location
    Austin, Texas
    Beans
    2,715

    Re: "cannot execute binary file"

    g++ -c hello.cpp -o output
    You need to get rid of that "-c"

    It's causing it to compile to an object file instead of an executable.

  3. #3
    Join Date
    Nov 2005
    Location
    Sweden
    Beans
    257
    Distro
    Kubuntu 9.10 Karmic Koala

    Re: "cannot execute binary file"

    Problem solved, guess I was compiling the wrong way after all
    All I had to do was "g++ hello.cpp" That's what I tried first but that time it didn't work...

    Quote Originally Posted by Wybiral View Post
    You need to get rid of that "-c"

    It's causing it to compile to an object file instead of an executable.
    aaaaaah, Well you learn something new everyday. Thanks!

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
  •