[C/C++] What about pushing the compiled executable

What about pushing the compiled executable to github ?
Is it necessary ? a good idea ? optional?
And what about ‘a.out’ as well ?

And if it is pushed, what is the git commit message ?

-m “Recompiled” ?

It’s generally not recommended or useful to commit the compiled executable. The C/C++ code is portable across multiple architectures while the executable is only good for build environments sufficiently similar to your own.

So, in other words, anyone who wants to see my code in action, will have to know how to clone my repo, open it in terminal or IDE, and know how to compile it, and run the executable ?

Yep. That’s part of why a Makefile should be included in your repo if you want others to compile your code.

You mean a set of instructions in the README.md file ?

What if I used ‘make’ instead of ‘gcc’ to compile my code ?

Instructions in the README are also good, but I mean a Makefile.

Does that have anything to do with ‘make’ ?

Yes, a Makefile is what lets you use make to compile a program.

I will probably just instruct them to install ‘gcc’ and ‘g++’ compiler and pass the source code to it with a ‘-o’ flag and the desired name of the executable.

If I push the binary to Github, after it’s cloned by someone, can they just run it with ./ ?

Another person will probably not be able to run it, no.

Part of the job of the C compiler is to compile the code for your computer. In general, a program compiled on one computer won’t run on another unless your are extremely lucky.

If they use gcc / g++ to compile on their end then it should work.

Yes. So long as you haven’t used any compiler specific features, then any compiler will work for someone that downloads your code. GCC, ICC, Clang, etc.

gcc/g++ on Linux and Windows, clang on Mac, I think.

You can run any of those compilers on Linux, Windows, or Mac.

The ‘executable’ that gets created is a little different from the interpreted languages. those source code files have to be passed into an interpreter and the only diff is that compiled languages have to be passed into a compiler. I shouldn’t dwell too much on the binary being pushed / hosted or not.

Compiled languages definitively are different than interpreted languages.

I’d just recommend that you keep the compiled binaries out of your repo - they’re big and others probably won’t be able to run them.

You can add a gitignore file to exclude them.

Yup. that’s what I was thinking.
And finally, how to create a C/C++ or other compiled language program where the user just double clicks and it launches it self either as an app or a console program ?

Honestly, all of my code only runs in the terminal so I don’t know anything about creating desktop applications that aren’t executed via the terminal.