Reputation: 83
I was following this tutorial on GNU compilers found here which does some simple compiling of a "hello world" c++ script "hello.cpp" by doing:
$ g++ -o hello hello.cpp
$ chmod a+x hello
$ ./hello
And it made me realise with the limited knowledge of compiling I have that I sometimes have to specify my output as an executable using "chmod a+x" and sometimes its already an executable without it (which was the case for me when I ran the above).
Is it perhaps a version thing of g++ perhaps?
Upvotes: 3
Views: 777
Reputation: 1490
chmod a+x
is mere a way to explicitly make sure it is an executable file. Not all compilers will definitely make the file executable, adding an explicit command to make it executable will make the script work with any compiler too chain. I think it is a good way, although seemingly redundant for gcc.
Upvotes: 1