g++ Permission denied

i use
Code:
FreeBSD 8.2-RELEASE amd64
i have this file main.cpp with code
Code:
#include<iostream>
using namespace std;
int main(){
cout<<"heloo";
return 0;}
i use
Code:
g++ -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070719  [FreeBSD]
and i try to compile the file main.cpp
Code:
g++ -o x -c main.cpp
and if i try ./x this is the result
Code:
%./x
./x: Permission denied.
what i do wrong ?
 
You did not set right permissions for the file (no execution flag set) do something like:
% chmod 755 ./x
 
xnl96 said:
... and i try to compile the file main.cpp
Code:
g++ -o x -c main.cpp
and if i try ./x this is the result
Code:
%./x
./x: Permission denied.
what i do wrong ?

You do not link the file. The option -c tells the compiler to create an object, which you force to be ./x instead of ./x.o - leave the -c option out and all should be well.
 
Back
Top