# How to build opencv with latest version of Gstreamer 1.18

**URL:** <https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662>\
**Category:** Python\
**Tags:** gstreamer, build\
**Created:** [June 3, 2021, 4:40pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662 "2021-06-03T16:40:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 3, 2021, 4:40pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/1 "2021-06-03T16:40:57Z")

</div>

what i am trying to achieve is to use latest version Gstreamer with opencv in Ubuntu 18.04  
Looking forward to hear.

Thanks

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 3, 2021, 4:50pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/2 "2021-06-03T16:50:21Z")

</div>

and what’s the issue?

---

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 3, 2021, 5:07pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/3 "2021-06-03T17:07:02Z")

</div>

need to build gstreamer, the version in the cmake stays 1.14 even i have manually changed the path to .so files of gstreamer  
Error : Make Error in modules/videoio/CMakeLists.txt:  
Imported target “ocv.3rdparty.gstreamer” includes non-existent path

```
"/usr/include/gstreamer-1.0"

```

in its INTERFACE\_INCLUDE\_DIRECTORIES. Possible reasons include:

- The path was deleted, renamed, or moved to another location.

- An install or uninstall procedure did not complete successfully.

- The installation package was faulty and references files it does not  
provide.

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 3, 2021, 5:29pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/4 "2021-06-03T17:29:26Z")

</div>

clear the build directory, or at least `CMakeCache.txt`

---

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 3, 2021, 5:30pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/5 "2021-06-03T17:30:25Z")

</div>

i tried that , then it’s not detecting gstreamer at all

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 3, 2021, 5:31pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/6 "2021-06-03T17:31:17Z")

</div>

have you successfully built gstreamer, or installed a package of gstreamer that contains development files (libraries, headers)?

---

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 3, 2021, 7:38pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/7 "2021-06-03T19:38:32Z")

</div>

/usr/bin/ld: /usr/local/lib/libavcodec.a(vc1dsp\_mmx.o): relocation R\_X86\_64\_PC32 against symbol `ff\_pw\_9’ can not be used when making a shared object; recompile with -fPIC  
/usr/bin/ld: final link failed: Bad value  
collect2: error: ld returned 1 exit status  
modules/videoio/CMakeFiles/opencv\_videoio.dir/build.make:461: recipe for target ‘lib/libopencv\_videoio.so.4.5.2’ failed  
make[2]: \*\*\* [lib/libopencv\_videoio.so.4.5.2] Error 1  
CMakeFiles/Makefile2:2392: recipe for target ‘modules/videoio/CMakeFiles/opencv\_videoio.dir/all’ failed  
make[1]: \*\*\* [modules/videoio/CMakeFiles/opencv\_videoio.dir/all] Error 2  
make[1]: \*\*\* Waiting for unfinished jobs…

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 3, 2021, 10:24pm UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/8 "2021-06-03T22:24:41Z")

</div>

that isn’t gstreamer, that’s ffmpeg

you need to build ffmpeg differently. see here, same error that says “recompile with -fPIC”, and same resolution: [Error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’ - #8 by crackwitz](https://forum.opencv.org/t/error-avstream-aka-struct-avstream-has-no-member-named-codec/3506/8)

---

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 4, 2021, 7:05am UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/9 "2021-06-04T07:05:42Z")

</div>

What i noticed is the gstreamer is not able to build with libav , is this also an issue due to ffmpeg?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 4, 2021, 7:10am UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/10 "2021-06-04T07:10:54Z")

</div>

libav\* (libavformat, libavcodec, …) are the libraries of ffmpeg. “ffmpeg”, in the context of OpenCV, means “ffmpeg libraries”.

gstreamer does not depend on ffmpeg.  
ffmpeg does not depend on gstreamer.

OpenCV can use either or both.

you did not show issues with building gstreamer itself. you don’t need to build gstreamer.

you showed issues with building OpenCV, where ffmpeg and/or gstreamer were the issue.

you need to provide specific information, i.e. precisely what you do, and all log outputs.

---

<div class="post-metadata">

**Author:** ![Thaha\_Mohammed.T.M](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/thaha_mohammed.t.m/32/2283_2.png) [@Thaha\_Mohammed.T.M](https://forum.opencv.org/u/Thaha_Mohammed.T.M)\
**Post date:** [June 4, 2021, 8:42am UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/11 "2021-06-04T08:42:11Z")

</div>

Apologies for the confusion. I am totally new to this.  
When i did the Gstreamer installation , i got a similar error regarding libgstav.  
So i disabled that certain sub-project and installed it.

After that i tried install OpenCV with that Gstreamer support.  
At that time i got the error i mentioned above.  
So i thought that was due to the disabled module.

As you shared above link which confirmed it’s an issue related to FFmpeg which i didn’t needed, so i removed it in cmake.list and builded OpenCV.  
And that helped me .  
Let me know if anything need to be clarified.  
Thanks again.

---

<div class="post-metadata">

**Author:** ![AlanWang](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alanwang/32/8080_2.png) [@AlanWang](https://forum.opencv.org/u/AlanWang)\
**Post date:** [June 16, 2023, 8:48am UTC](https://forum.opencv.org/t/how-to-build-opencv-with-latest-version-of-gstreamer-1-18/3662/12 "2023-06-16T08:48:15Z")

</div>

I encountered the same issue. The error message indicate the real problem. The header file directory for gstreamer-1.0 does not exist. If you build gstreamer-1.0 by yourself and install it somewhere, let’s say ~/\_install, then you should copy the header like this:  
sudo cp ~/\_install/include/gstreamer-1.0 /user/include/
