I've successfully compiled a program (including SDL) on my computer (Ubuntu 12) and the a.out
runs just fine!
Now, if I send the a.out
to a friend, it just does not work. (gives simple error message ("Can't be run.."
) or something)
But if I compile the corresponding source-file on my friends computer again, it works!
How do I have to pack/compile/make my program to make it runnable on other computer?
out is a file format used in older versions of Unix-like computer operating systems for executables, object code, and, in later systems, shared libraries. This is an abbreviated form of "assembler output", the filename of the output of Ken Thompson's PDP-7 assembler.
out is the default executable, since you didn't tell GCC what to name it (by using -o ). Just typing a. out won't run it, because it's in the current directory, and Linux doesn't put the current directory in the path like other broken OSes do, so you have to type ./a. out to run it.
Programs are written in a particular language which is then converted into machine code so that the computer can understand and execute the instructions. This process is known as compilation, and the machine code that is generated is known as an executable.
Executable are often specific to the environment/machine they were created on. Even if the same processor/hardware is involved, there may be dependencies on libraries that may prevent executables from just running on other machines.
Can you just send the source code with instructions to compile? Assuming there is no NDA or other issues preventing that approach (I only suggest that since you mentioned this worked for you)
Of course, in the end it is possible, after all that's how binaries are distributed, but they will be carefully constructed and will have statically linked libraries (ie everything is part of the executable).
Ask your friend to do the following:
chmod +x a.out
ldd a.out
What does he see? I assume, of course, that the two environments are largely similar (e.g., both run Ubuntu, etc.)
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