Exec format error. Wrong Architecture.

Hi

I used gcc -c -o test.exe test.cpp, there was no compilation error, but when i ran test.exe on the command line, it gave me:

Exec format error. Wrong Architecture.

how should I fix this error?

thanks

sjang
It's difficult to say without seeing the contents of test.cpp. However assuming your .cpp is C++ code, you're compiling with a C compiler, try using g++ instead of gcc.
Hi

test.cpp is a c++ program. I tried g++ -c -o test.exe test.cpp but still got the same error. Any ideas?

thanks

sjang
The problem might be because you keep using the -c flag. You can't directly execute an .obj file, no matter what its extension.

g++ test.cpp -o test

If that doesn't fix it, then exactly what OS, hardware, and version of GCC are you using?
Hi

getting rid of that -c fixed it. Thanks for helps!

sjang
Topic archived. No new replies allowed.