1

I have compiled a cpp program, but now I cannot run it. The error message I get says command not found.

I compiled it by running this command:

gcc `pkg-config --cflags opencv` OpenCV_ViolaJones.cpp -o OpenCV_ViolaJones `pkg-config --libs opencv`

It's compiled successfully. However, when I run it:

./OpenCV_ViolaJones

It shows me "Command not found". I am pretty sure that I am in the same directory and using the correct name.

Could you explain this to me, please? Thank you very much!

2
  • Are you sure that it successfully compiled? You're trying to compile a C++ program (I assume, from the filename) with the C compiler. Please post the output of your gcc call. I'm willing to bet your compilation is failing, so the program you're attempting to run doesn't actually exist.
    – Kyle
    May 23, 2013 at 19:56
  • 3
    Possible duplicate of Can't execute .out files, getting permission denied Though the error message is not exactly the same, the further information provided in that comment indicated that the file existed, had wrong permissions, and (as it basically always the case when people try to do this on a just-compiled binary that lacks executable permissions) chmod +x left them unchanged. The answers there cover this. Oct 27, 2019 at 8:54

1 Answer 1

-1

You need to make it executable before being able to run it like that:

chmod +x OpenCV_ViolaJoanes

will make your compiled program executable and you will be then able to run it.

1
  • Thank you for your advice. Well, when I "ll" it, it show that -rw-------. After I use chmod, it does not change anything. I just want to know why and how. And even when I use "sudo", it show me that command not found. I am pretty sure that OpenCV works correctly, since I have run some of its examples, they works.
    – Fei
    May 24, 2013 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .