View Full Version : problems with gcc.....(permission denied)

September 6th, 2006, 11:02 PM
the problem is that when i try to run the .o file , i get an error message..permission denied.
the file was compiled with no errors.
iv done c prgs. on FC before but never faced such a problem..


September 6th, 2006, 11:12 PM
are you running with sudo ?

September 7th, 2006, 09:25 AM
no.....actually its not clear how to use sudo exactly?
does it make any diff?

September 7th, 2006, 09:37 AM
How about sudo -s?
Then try to run it.

September 7th, 2006, 09:41 AM
this is what exactly happens or is happening now.....

navneet@ubuntu4fedora:~/C$ sudo -s
root@ubuntu4fedora:~/C# ./try1.o
bash: ./try1.o: cannot execute binary file

September 7th, 2006, 09:54 AM
The .o is an object file, not an executable file. It needs to be linked before it is executable.

gcc -o try1 try1.c
You may be using the -c flag which says "just compile, don't link".

September 7th, 2006, 10:03 AM
Damn non-responsive server.

September 7th, 2006, 10:03 AM
thanks a lot...
its working now.....
though strange as when i used FC it never happened to be the case....
moreover then what is the significance of gcc -c ?

thanks again.

September 7th, 2006, 10:05 AM
You use the -c flag when you are compiling multiple files but you then want to link into a single executable.

gcc -c -o foo.o foo.c
gcc -c -o bar.o bar.c
gcc -o foobar foo.o bar.o

September 7th, 2006, 10:10 AM
so basically you want to say there is a diff b/w an object file and an executble ?

then how is it so that we can straight away run the binaries? they are object files or execs.?

September 7th, 2006, 10:16 AM
Yes there is a difference between an object file and an executable.

The command "gcc -o foo foo.c" does both the compile and link phase and doesn't leave you with an object file lying around.

You cannot execute an object file.

September 10th, 2006, 06:35 AM
thanks a lot thumper....that really helped.
one more thing.......iv made a small program to check password entered by the user..now i want to implement it as the default login prg for my pc....i.e,when a user logs on to ubuntu on my pc ...he gets instead of default login screen ,he sees my passwd prg.
how should i do away with that?
thank you.

September 10th, 2006, 11:00 PM
That would be a really bad idea.