# g++  Permission denied



## xnl96 (Oct 12, 2011)

i use 
	
	



```
FreeBSD 8.2-RELEASE amd64
```
 i have this file main.cpp with code 
	
	



```
#include<iostream>
using namespace std;
int main(){
cout<<"heloo";
return 0;}
```
i use 
	
	



```
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
	
	



```
g++ -o x -c main.cpp
```
 and if i try ./x this is the result 
	
	



```
%./x
./x: Permission denied.
```
 what i do wrong ?


----------



## expl (Oct 12, 2011)

You did not set right permissions for the file (no execution flag set) do something like:
`% chmod 755 ./x`


----------



## Crivens (Oct 12, 2011)

xnl96 said:
			
		

> ... and i try to compile the file main.cpp
> 
> 
> 
> ...



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.


----------



## xnl96 (Oct 12, 2011)

thanks a lot


----------

