# After using CMake to build opencv 4.5.2 (MinGW Makefiles) the lib folder is empty

**URL:** <https://forum.opencv.org/t/after-using-cmake-to-build-opencv-4-5-2-mingw-makefiles-the-lib-folder-is-empty/3138>\
**Category:** C++\
**Tags:** build\
**Created:** [May 5, 2021, 1:08am UTC](https://forum.opencv.org/t/after-using-cmake-to-build-opencv-4-5-2-mingw-makefiles-the-lib-folder-is-empty/3138 "2021-05-05T01:08:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MagicQuest3](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/magicquest3/32/724_2.png) [@MagicQuest3](https://forum.opencv.org/u/MagicQuest3)\
**Post date:** [May 5, 2021, 1:08am UTC](https://forum.opencv.org/t/after-using-cmake-to-build-opencv-4-5-2-mingw-makefiles-the-lib-folder-is-empty/3138/1 "2021-05-05T01:08:27Z")

</div>

I didn’t change any of the CMake options when I clicked generate and the only thing I did change was line 236 of OpenCVDownload.cmake because it couldn’t extract  
/.cache/ade/b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip  
after generating it I setup the CMakeLists.txt in CLion

```
cmake_minimum_required(VERSION 3.17)
project(opencvtest)

set(CMAKE_CXX_STANDARD 14)
set(OpenCV_STATIC_LIBRARIES TRUE)
set(OpenCV_DIR "E:/CPP/OPENCV/opencv/build")

find_package( OpenCV REQUIRED )
add_executable(opencvtest main.cpp)
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( opencvtest ${OpenCV_LIBS} )
MESSAGE("OpenCV_LIBS: " ${OpenCV_LIBS} ) 
MESSAGE("OpenCV_Include: " ${OpenCV_INCLUDE_DIRS} )

```

The CMakeLists.txt finishes running without error but when I run main.cpp ([just a demo from the opencv docs](https://docs.opencv.org/master/db/deb/tutorial_display_image.html))  
I get the no rule to make target ‘E:/CPP/OPENCV/opencv/build/lib/libopencv\_gapi452.dll.a’ error (because the lib folder is empty)  
I have tried building opencv twice but the lib folder has still come up empty.

---

<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:** [May 5, 2021, 6:39am UTC](https://forum.opencv.org/t/after-using-cmake-to-build-opencv-4-5-2-mingw-makefiles-the-lib-folder-is-empty/3138/2 "2021-05-05T06:39:23Z")

</div>

> [@MagicQuest3](#):
>
> when I clicked generate

this will only generate makefiles, it won’t compile and link libraries, you need to invoke

```
 mingw32-make install

```

from your build folder. this will build & install the opencv libs & headers to `build\install`

> [@MagicQuest3](#):
>
> because it couldn’t extract  
> /.cache/ade/b624b995ec9c439cbc2e9e6ee940d3a2-v0.1.1f.zip

like it or not, you need a network connection, while running cmake here, it tries to download a couple of things.

> [@MagicQuest3](#):
>
> no rule to make target ‘E:/CPP/OPENCV/opencv/build/lib/libopencv\_gapi452.dll.a’

it could not build the opencv\_gapi module, because the ade dependancy was missing. either get the download working, or you have to disable the gapi module by unchecking `BUILD_opencv_gapi` and `WITH_ADE` in cmake-gui

so again, before you can compile _your_ program, you have to see, that the libs were built correctly

then, this:

> [@MagicQuest3](#):
>
> `set(OpenCV_DIR "E:/CPP/OPENCV/opencv/build")`

should be:

```
set(OpenCV_DIR "E:/CPP/OPENCV/opencv/build/install")

```

also:

```
set(OpenCV_STATIC_LIBRARIES TRUE)

```

assumes, you actually _build static opencv libs_ , which would require unchecking

```
BUILD_SHARED_LIBS

```

in cmake before, when building the libs.

---

<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:** [May 5, 2021, 7:22am UTC](https://forum.opencv.org/t/after-using-cmake-to-build-opencv-4-5-2-mingw-makefiles-the-lib-folder-is-empty/3138/3 "2021-05-05T07:22:09Z")

</div>

tl:dr;

please revert your changes, make sure you’re online, rerun cmake-gui and show us the output
