# How to install and use opencv in manjaro linux

**URL:** <https://forum.opencv.org/t/how-to-install-and-use-opencv-in-manjaro-linux/6971>\
**Category:** C++\
**Tags:** linux\
**Created:** [January 4, 2022, 12:39pm UTC](https://forum.opencv.org/t/how-to-install-and-use-opencv-in-manjaro-linux/6971 "2022-01-04T12:39:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thenujan\_Sandramohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thenujan_sandramohan/32/4139_2.png) [@Thenujan\_Sandramohan](https://forum.opencv.org/u/Thenujan_Sandramohan)\
**Post date:** [January 4, 2022, 12:39pm UTC](https://forum.opencv.org/t/how-to-install-and-use-opencv-in-manjaro-linux/6971/1 "2022-01-04T12:39:08Z")

</div>

I’m trying to compile a c++ file using g++ in manjaro linux .  
I installed opencv from official manjaro repos but i’m getting warning from vscode

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opencv/original/2X/9/984cb4c5fbe23b9fa7d3a60df67a6d8e6d308d8f.png)

i have also tried adding

```auto
`pkg-config --cflags --libs opencv`

```

to as an argument to g++ but it still fails.  
I tried to compile from source and the build but it failed

i tried installing opencv2 from aur and it failed

```auto
/home/thenujan/opencv2-opt/src/opencv-2.4.13.6/modules/core/include/opencv2/core/internal.hpp:195:12: fatal error: tbb/tbb_stddef.h: No such file or directory
  195 | # include "tbb/tbb_stddef.h"
      | ^ ~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/build.make:85: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1817: modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
==> ERROR: A failure occurred in build().

```

---

<div class="post-metadata">

**Author:** ![Thenujan\_Sandramohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thenujan_sandramohan/32/4139_2.png) [@Thenujan\_Sandramohan](https://forum.opencv.org/u/Thenujan_Sandramohan)\
**Post date:** [January 4, 2022, 12:40pm UTC](https://forum.opencv.org/t/how-to-install-and-use-opencv-in-manjaro-linux/6971/2 "2022-01-04T12:40:28Z")

</div>

`locate opencv4.pc ` returned this

```auto
/usr/lib/pkgconfig/opencv4.pc

```

so i tried

```auto
g++ -o out.ou `pkg-config --cflags opencv4` main.cpp

```

it worked

And then had to use the one below to avoid some other errors

```auto
g++ $(pkg-config opencv4 --cflags) -std=c++17 foo.cpp $(pkg-config opencv4 --libs) -o foo.o

```

```auto
/usr/bin/ld: main.cpp:(.text+0xf9): undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/usr/bin/ld: main.cpp:(.text+0x130): undefined reference to `cv::waitKey(int)'
/usr/bin/ld: main.cpp:(.text+0x13c): undefined reference to `cv::Mat::~Mat()'
/usr/bin/ld: main.cpp:(.text+0x1cb): undefined reference to `cv::Mat::~Mat()'

```

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [January 8, 2022, 2:50pm UTC](https://forum.opencv.org/t/how-to-install-and-use-opencv-in-manjaro-linux/6971/3 "2022-01-08T14:50:07Z")

</div>

> [@Thenujan\_Sandramohan](#):
>
> `opencv-2.4.13.6`

this is entirely outdated, no more maintained, do not use that.  
please rather build opencv libs locally from github src
