Creating Linux executable using GCC

I use Linux Ubuntu Intrepid Ibex and compile C ++ files with GCC, but when I compile, gcc creates **. out * file, i.e. an executable file, but how can I make Linux executables? Thanks!

+6
c ++ gcc linux ubuntu executable
source share
3 answers

This executable is “Linux executable”, that is, executable on any of the latest Linux systems. You can rename the file as you wish with

rename a.out your-executable-name 

or better yet, tell GCC where to put your output file using

 gcc -o your-executable-name your-source-file.c 

Keep in mind that before Linux systems allow you to run the file, you may need to set its “executable bit”:

 chmod +x your-executable-name 

Also remember that on Linux the file extension has very little to do with what it really is - your executable file can be called something , something.out or even something.exe , and as long as it is created by GCC, and you do chmod +x in the file, you can run it as a Linux executable.

+18
source share

To create an executable file called myprog , you can invoke gcc as follows:

 gcc -c -o myprog something.c 

You can also just rename the * .out gcc file, generating the name you want.

+4
source share

This is an executable file. If you don't like a.out, you can pass the -o flag to the compiler. If the executable is not marked with an executable bit, you need to do it yourself:

 chmod u+x ./a.out ./a.out 

NTN.

+2
source share

All Articles