On Oct 8, 7:40 pm, "Andrew Koenig" <a...@acm.orgwrote:
"ravi" <gototh...@gmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
I written and compiled a c++ program using g++ no errors or
warning are reported.
But when I run it , reporting an error : ERROR: Wrong magic number.
What is the reason for this error?
Either you didn't link it, or the file you are executing is
not the one you think it is.
He didn't give a too many details, but in a lot of Unix
distributions today, the default $PATH doesn't have . in it
(which is as it should be for non-developers). And I find a lot
of files have the x bit set when they shouldn't. Combine the
two, and that could very easily explain his symptoms.
Depending on the shell being used, either "type command" or
"which command" can be used to see which executable is actually
being found. More generally, however, when testing a just built
executable, it's usually preferable to invoke it with
../filename. (Or maybe I just believe this because so many of my
test programs are called simply test:-), and even with . in the
path, test and ./test invoke different things.)
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34