Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running a.out on another computer

Tags:

c++

linux

sdl

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?

like image 703
user1511417 Avatar asked Jul 11 '12 13:07

user1511417


People also ask

What is a out command?

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.

How do you run out in GCC?

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.

What happens when you run a executable program?

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.


2 Answers

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).

like image 89
Levon Avatar answered Oct 02 '22 11:10

Levon


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.)

like image 23
Happy Green Kid Naps Avatar answered Oct 02 '22 11:10

Happy Green Kid Naps