Ask Your Question

Revision history [back]

How do I install and use OpenCV on Arch Linux (C++)?

I've installed the opencv package from the Arch Repos but when I try to import opencv.hpp, I can only find opencv4/opencv2/opencv.hpp when importing (I am using Visual Studio Code with default settings).

I wrote a little program to test if this was even importing correctly and I get this error when compiling with g++

~/.../camera-software/src >>> g++ main.cpp
In file included from main.cpp:1:
/usr/include/opencv4/opencv2/opencv.hpp:48:10: fatal error: opencv2/opencv_modules.hpp: No such file or directory
   48 | #include "opencv2/opencv_modules.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

This is the program I wrote:

#include "opencv4/opencv2/opencv.hpp"
#include <iostream>

using namespace std;

int main() {
    printf("Hello World!\n");
    return 0;
}

I've tried including opencv4/opencv2/opencv_modules.hpp but I get the same error.