LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   cannot execute binary file (https://www.linuxquestions.org/questions/linux-from-scratch-13/cannot-execute-binary-file-255356/)

Quest101 11-15-2004 09:34 PM

cannot execute binary file
 
Hey ,
I am trying to execute a simple binary file hello.o on Red hat 9.0

i enter the commnand : ./hello.o

The error message received is : bash: ./hello.o: cannot execute binary file

any help would be greatly appreciated

mAineAc 11-15-2004 09:45 PM

what are the permissions on it? try chmod a+x hello.o and see if that helps

Quest101 11-15-2004 10:17 PM

mAineAc thanx but i had already tried that the permission printout for the file look like :

-rwxr-xr-x hello.o

any other suggestions ??

XsuX 11-15-2004 10:57 PM

Is it a C/C++ program? If so, then do you have the source code? If so, then try recompiling it. I had trouble like this on my university's UNIX server, and some weird bug makes it so you have to recompile almost everytime you run the prog.
If my assertions were wrong, then ignore this post, cuz it offers nothing. :p

Quest101 11-15-2004 11:30 PM

thanx again but , thats doesnt seem to be the problem

mAineAc 11-16-2004 06:52 AM

is this a program you wrote? If it is, is there any way you can share the source so that we can see what the problem is? You will get an error like that if you are trying to use some win api. like if you wrote it and compiled it with winc++ You didn't give any information about how it was compiled, written or anything except your trying to run it on rh 9. It is kinda hard to help a person in the dark.

Quest101 11-16-2004 09:33 AM

Hey i am jus trying to compile a simple hello world program .....

#include<iostream>
using namespace std ;

int main ()
{
cout << "hello " ;
return 0 ;
}

i saved it as hello.cpp

from the command terminal i used gcc :

gcc -c hello.cpp

which was good since it compiled giving a hello.o file

this was where i encountered the problem. In trying to execute the program:

./hello.o

i got the error message]

bash: ./hello.o: cannot execute binary file

I hope this information give u a clearer pic of what the problem actually is , thanx for the help

mAineAc 11-16-2004 10:56 AM

ok then do:
g++ hello.cpp -o hello

Quest101 11-19-2004 01:16 PM

mAineAc, thanx for the help , the commands worked !


All times are GMT -5. The time now is 04:12 AM.