You need to compile the program for the type of machine you're going to run it on. The type of machine you compiled this for does not match your school's computer.
If the school has a compiler installed on its server, use it to compile your program.
You can see what type of executable you have with the file
command under UNIX, Linux and MacOS X. For example:
$ file /bin/ls # on my Linux box
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
$ file /bin/ls # on my MacBook Pro
/bin/ls: Mach-O usiversal binary with 2 architectures
/bin/ls (for architecture x86_64): Mach-O 64-bit executable x86_64
/bin/ls (for architecture i386): Mach-O executable i386
Usually, different operating systems are able to at least minimally identify executables for foreign systems, but not always. That is, it'll identify that it's foreign, but might not be able to identify which foreign system.
If you are compiling the code on your school's server, then something else strange is afoot. The file
command above should help rule out certain things. BTW, you might list out what compiler flags you're using, and the output of file
for the version that works and the version that does not.
One other thing to check: Make sure your final compile step does not include the -c
flag to g++. That flag tells G++ that you're building an intermediate object, not the final object.