The code snippet:

#include <iostream>
using namespace std;

int main(){
    unsigned int a, b, diff;
    diff = a - b;
    if(diff % 10 == 9){
    return 0;

The command used to compile:

g++ -Wall -Wextra -Werror -c main.cpp -o main.o

The error:

bash: ./main: No such file or directory

Error when 'main.o' is used:

bash: ./main.o: Permission denied

I am using Ubuntu 16.04 LTS.

g++ -Wall -Wextra -Werror main.cpp -o main

Don't use the -c flag if you want to create an executable.


If you press Tab it will autocomplete.

  • I get the error 'Permission denied', when I use 'main.o'. – V.I.L Jul 4 '18 at 7:57
  • I updated gcc command and renamed output file to main – Eugen M Jul 4 '18 at 8:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.