How to execute the .o file?

Asked by Subhranshu Dwivedi

Hi,

I m new to Ubuntu 8.10
and i m learning C programming
i have installed Ajunta
here i compiled >>>>

#include <stdio.h>
int main()
{
 printf("Enter the area of the circle\n ");
}

till here i got it successfull
i have saved this programme hello.cpp to my desktop.
after complilation i have got a hello.o generated in the desktop...

now the problem is how to execute it.

Please Suggest......

Subhranshu Dwivedi

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu anjuta Edit question
Assignee:
No assignee Edit question
Solved by:
Simone Cianfriglia
Solved:
Last query:
Last reply:
Revision history for this message
Simone Cianfriglia (crimer) said :
#1

Open terminal, cd to the directory containing hello.o then:

chmod u+x hello.o
./hello.o

Revision history for this message
Subhranshu Dwivedi (subhranshu) said :
#2

Hi Crimer,

i just tried it, with these hit and trials but no out put......

subhranshu@Subhranshu-laptop:~$ cd /home/subhranshu/Desktop
subhranshu@Subhranshu-laptop:~/Desktop$ chmod u+x hello.o ./hello.o
subhranshu@Subhranshu-laptop:~/Desktop$ chmod u+x hello.o
subhranshu@Subhranshu-laptop:~/Desktop$ chmod u+x hello.o
subhranshu@Subhranshu-laptop:~/Desktop$ ./hello.o
bash: ./hello.o: cannot execute binary file

i hope i m doing some thing wrong
please suggest.....

regards,

Subhranshu Dwivedi

Revision history for this message
Best Simone Cianfriglia (crimer) said :
#3

Go to the directory containing your cpp file then:

g++ hello.cpp -o hello
chmod u+x hello
./hello

It should work...

Revision history for this message
Subhranshu Dwivedi (subhranshu) said :
#4

heyy thanx man its working

u are great......

Revision history for this message
Subhranshu Dwivedi (subhranshu) said :
#5

Thanks Crimer, that solved my question.

Revision history for this message
Subhranshu Dwivedi (subhranshu) said :
#6