So when I try to run a compiled C program on my school's "hercules" server, it runs as I would normally expect it to. However, I've got an assignment that requires the use of forks, and running programs that fork on that server is forbidden, instead, I am to run them by remotely connecting to one of several Linux machines and running it there, from command line
However, any attempt to do so gives me this error:
shell2: Exec format error. Binary file not executable.
Altogether, my command prompt looks like this:
a049403[8]% shell2
shell2: Exec format error. Binary file not executable.
I've got the shell2 file in the working directory, when I type "ls" it shows it with the * character indicating it is notionally an executable. I've tried setting its permissions to 777. It produces the same error for other C programs which I have been working with and running, and "hercules" can run the exact same file without any difficulties or complaints. My make file for this particular program looks like this:
all: shell2
Basics.o: Basics.c Basics.h
cc -c Basics.c
doublinked.o: doublelinked.c doublelinked.h
cc -c doublelinked.c
main.o: main.c Basics.h doublelinked.h
cc -c main.c
shell2: main.o Basics.o doublelinked.o
cc main.o Basics.o doublelinked.o -o shell2
clean:
rm -f *o shell2
...and if I re-run the makefile it seems to build the program with no difficulties.
So, and reason an environment that can compile C programs would be unable to run them? Any likely workarounds?
file yourprog /bin/shsay on the target machine? If it doesn't say much the same thing, the trouble is what the error message says — your binary was prepared on a machine but is not executable on the machine where you're trying to run it. It is not clear what 'hercules' means or which O/S it runs, but it appears to be incompatible with the Linux machines where you try to run it. Do the compilation on the Linux machines, not on 'hercules'.make clean, thenmake allon your linux box.