May 21, 2008 at 6:00pm UTC
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
May 21, 2008 at 6:06pm UTC
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.
May 21, 2008 at 7:00pm UTC
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
May 21, 2008 at 8:17pm UTC
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?
May 21, 2008 at 8:31pm UTC
Hi
getting rid of that -c fixed it. Thanks for helps!
sjang