Ask Your Question
0

compiling using g++

asked 2014-03-06 05:34:24 -0600

Oded gravatar image

updated 2014-03-07 04:25:31 -0600

Jomoos gravatar image

After installing gcc and gcc-c++ using yum, I tried to compile some extremely simple c++ programs, those of the kind that print "hello".

  1. I used g++ -c prog.o prog.cpp and retrived the prog.o file without any problems
  2. I used g++ -o prog.exe prog.o and retrived the prog.exe file without any problems

BUT, when i tried to run the program in the terminal by writing prog, I get

bash: prog: command not found...

does anyone knows why?? I've been trying to do that for some hours now...

edit retag flag offensive close merge delete

Comments

1

Can you run "ls -la prog.exe" ? Maybe the execution flag is not set.

keramidas gravatar imagekeramidas ( 2014-03-09 13:06:17 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2014-03-06 07:31:21 -0600

skytux gravatar image

You should run prog.exe, not prog, because you called it prog.exe:

./prog.exe

HTH,

Germán.

edit flag offensive delete link more
0

answered 2014-03-09 01:33:32 -0600

Oded gravatar image

updated 2014-03-09 01:34:11 -0600

Of course i tried that too, neigher works. Did i have to write "./prog.exe"? Writing "prog.exe" is not enough? Thanks again

edit flag offensive delete link more

Comments

So, apperantly Mr. skytux was partly right. It doesn't matter if i write "prog" or "prog.exe", but adding ./ before "prog" solved the problem. I realy wonder why... what does ./ means? i mean, i was in the right folder that contained the file prog.exe...

Oded gravatar imageOded ( 2014-03-09 17:03:00 -0600 )edit

Sounds like an execution flag is amiss... chmod +x prog.exe ...without which bash (or any other shell) tries to find 'prog' from the places told in $PATH variable.

"./" more or less stands for "within the current directory", and AFAIK implies execution whether executable flag is set or not.

daikane gravatar imagedaikane ( 2014-03-11 18:59:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-03-06 05:34:24 -0600

Seen: 223 times

Last updated: Mar 09 '14