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!

Zanna
  • 69,223
  • 56
  • 216
  • 327
Fei
  • 19
  • 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 '13 at 19:56
  • 3
    Possible duplicate of [Can't execute .out files, getting permission denied](https://askubuntu.com/questions/44675/cant-execute-out-files-getting-permission-denied) Though the error message is not exactly the same, the [further information provided in that comment](https://askubuntu.com/questions/299218/compiled-executable-cannot-run#comment376868_299231) 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. – Eliah Kagan Oct 27 '19 at 08:54

1 Answers1

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

Bruno Pereira
  • 72,895
  • 33
  • 199
  • 223
  • 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 '13 at 14:46