To clarify, this is a question about binary Linux executables, not scripts, which can also be executable and also often lack an extension.
In my experience, most Linux binary executables lack a file extension; e.g. most of the files in the /bin directory on Linux systems lack an extension.
On the other hand, most of the files in the /lib directory have .so in their file extension, and also have executable permissions. Trying to execute an .so file directly usually results in seg fault or some error, which makes sense because shared libraries are usually intended to be dynamically linked. But as I understand it, if the .so file has a main() entrypoint, then you can run it as an executable as you would a normal executable (i.e. a file without an extension).
My questions:
.so extension) and an executable file ([none] extension)? Is it just whether a main() entrypoint is defined?.so extension) and compiling code into a Linux executable ([none] extension).Edit: This question talks about how to build an .so file using gcc command line, but doesn't identify the differences between building an .so versus a normal executable.
main() function. It also contains position independent code that may or may not be the case for executables. If you do put a main() function in the library, you still need to link it with a normal object file (containing no main() function).-fpic or -fPIC to generate position-independent code (PIC) suitable for use in a shared library.Nothing prevents you from creating an executable called myexe.so though, but it can't be used as a shared library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With