Running Compiled Program - "Invalid Argument"
I have a simple Hello World C ++ program (main.cpp):
#include <iostream>
using namespace std;
int main ( void ) {
cout << "Hello world" << endl;
return ( 0 );
}
I will compile it through
g++ -Wall -pedantic -Wno-long-long -Werror -c main.cpp
then add permission to be executable
chmod +x main.o
and try to run it
./main.o
My console returns
-bash: ./main.o: Invalid argument
What am I pushing?
The parameter -ctells the compiler to simply compile the source file in an "object file" and not link it.
Without the link step, the object file you receive is not executable, but simply an intermediate step. What you probably want to do is
g++ -o main.x -Wall -pedantic -Wno-long-long -Werror main.cpp
main.x ( .x .o ); , chmod . (: "lint-style" - -Wextra; -O3)
, , ; , , , , ( , : OpenOffice.org 4 ).
, g++ ( ld, , ), , Makefile .