# Build OpenCV 4.5.2 with freetype library

**URL:** <https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825>\
**Category:** C++\
**Tags:** build, freetype\
**Created:** [August 18, 2021, 10:08am UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825 "2021-08-18T10:08:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 10:08am UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/1 "2021-08-18T10:08:23Z")

</div>

Hi dear developers!!! I need some help with building the OpenCV 4.5.2 with CMake and freetype lib enabled. I add the extra\_module\_pass and put the contrib modules inside, everything configures and builds good, except the freetype library, i cant find it in the install folder (not in includes not in libs) it seems like CMake doesnt build it at all.

Also i tried to turno ON WITH\_FREETYPE flag, it doesnt help!!!

Please give me a hand with a problem

---

<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:** [August 18, 2021, 10:28am UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/2 "2021-08-18T10:28:41Z")

</div>

- did you install [freetype and harfbuzz](https://github.com/opencv/opencv_contrib/tree/master/modules/freetype) dependancies ?
- yes, you need ` WITH_FREETYPE=ON`
- please show the _complete_ cmake console output (rather long, but it has hints)
- make sure, you use _exactly_ the same version for both opencv main and contrib repos (if you want to use 4.5.2, check out the 4.5.2 branch in contrib, too !)
- please also see [the related answer here](https://forum.opencv.org/t/using-building-freetype-with-opencv-c/3424)

---

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 12:09pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/3 "2021-08-18T12:09:06Z")

</div>

Thank you for a quick reply!

1. I installed freetype and harfbuzz using vcpkg and i don’t know how to link them to CMake during the OpenCV configuration and generation. Could you please tell in more detailes how to link freetype and harfbuzz to the cmake?

2. I use the same versions of OpenCV master branch and contrib brach (4.5.3) , sorry i wrote 4.5.2 before;

3. Here is the cmake console:

```auto
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
Detected processor: AMD64
Found PythonInterp: C:/Users/User/AppData/Local/Programs/Python/Python39/python.exe (found suitable version "3.9.6", minimum required is "2.7") 
libjpeg-turbo: VERSION = 2.1.0, BUILD = opencv-4.5.3-dev-libjpeg-turbo
Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources
OpenJPEG: VERSION = 2.4.0, BUILD = opencv-4.5.3-dev-openjp2-2.4.0
OpenJPEG libraries will be built from sources: libopenjp2 (version "2.4.0")
Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
Could NOT find BLAS (missing: BLAS_LIBRARIES) 
Could NOT find LAPACK (missing: LAPACK_LIBRARIES) 
    Reason given by package: LAPACK could not be found because dependency BLAS could not be found.

VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: D:/build/opencv_453/build/python_loader
Module opencv_alphamat disabled because the following dependencies are not found: Eigen
freetype2: NO
harfbuzz: NO
Julia not found. Not compiling Julia Bindings. 
CMake Warning (dev) at extramodules/modules/matlab/cmake/init.cmake:24 (set):
  Cannot set "DOXYGEN_BLACKLIST": current scope has no parent.
Call Stack (most recent call first):
  cmake/OpenCVModule.cmake:298 (include)
  cmake/OpenCVModule.cmake:364 (_add_modules_1)
  cmake/OpenCVModule.cmake:385 (ocv_glob_modules)
  CMakeLists.txt:917 (ocv_register_modules)
This warning is for project developers. Use -Wno-dev to suppress it.

Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.
Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.
Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h
Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h
Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags
Tesseract: NO
Module opencv_python3 disabled because opencv_python_bindings_generator dependency can't be resolved!
Allocator metrics storage type: 'long long'
Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/build/opencv_453/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake
opencv_dnn: filter out cuda4dnn source code
Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.rvv.cpp
wechat_qrcode: Download: detect.caffemodel
wechat_qrcode: Download: detect.prototxt
wechat_qrcode: Download: sr.caffemodel
wechat_qrcode: Download: sr.prototxt
highgui: using builtin backend: WIN32UI
rgbd: Eigen support is disabled. Eigen is Required for Posegraph optimization
xfeatures2d/boostdesc: Download: boostdesc_bgm.i
xfeatures2d/boostdesc: Download: boostdesc_bgm_bi.i
xfeatures2d/boostdesc: Download: boostdesc_bgm_hd.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_064.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_128.i
xfeatures2d/boostdesc: Download: boostdesc_binboost_256.i
xfeatures2d/boostdesc: Download: boostdesc_lbgm.i
xfeatures2d/vgg: Download: vgg_generated_48.i
xfeatures2d/vgg: Download: vgg_generated_64.i
xfeatures2d/vgg: Download: vgg_generated_80.i
xfeatures2d/vgg: Download: vgg_generated_120.i
data: Download: face_landmark_model.dat
CMake Warning at cmake/OpenCVGenSetupVars.cmake:54 (message):
  CONFIGURATION IS NOT SUPPORTED: validate setupvars script in install
  directory
Call Stack (most recent call first):
  CMakeLists.txt:1025 (include)

General configuration for OpenCV 4.5.3-dev =====================================
  Version control: unknown

  Extra modules:
    Location (extra): D:/build/opencv_453/extramodules/modules
    Version control (extra): unknown

  Platform:
    Timestamp: 2021-08-18T11:23:04Z
    Host: Windows 10.0.19043 AMD64
    CMake: 3.21.1
    CMake generator: Visual Studio 16 2019
    CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/MSBuild/Current/Bin/MSBuild.exe
    MSVC: 1929
    Configuration: Debug Release

  CPU/HW features:
    Baseline: SSE SSE2 SSE3
      requested: SSE3
    Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
      requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (15 files): + SSSE3 SSE4_1
      SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (29 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
      AVX512_SKX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX

  C/C++:
    Built as dynamic libs?: NO
    C++ standard: 11
    C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe (ver 19.29.30133.0)
    C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP /MT /O2 /Ob2 /DNDEBUG 
    C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /EHa /wd4127 /wd4251 /wd4324 /wd4275 /wd4512 /wd4589 /MP /MTd /Zi /Ob0 /Od /RTC1 
    C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
    C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /MT /O2 /Ob2 /DNDEBUG 
    C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /fp:precise /MP /MTd /Zi /Ob0 /Od /RTC1 
    Linker flags (Release): /machine:x64 /NODEFAULTLIB:atlthunk.lib /INCREMENTAL:NO /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib
    Linker flags (Debug): /machine:x64 /NODEFAULTLIB:atlthunk.lib /debug /INCREMENTAL /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib
    ccache: NO
    Precompiled headers: NO
    Extra dependencies: wsock32 comctl32 gdi32 ole32 setupapi ws2_32
    3rdparty dependencies: libprotobuf ade ittnotify libjpeg-turbo libwebp libpng libtiff libopenjp2 IlmImf zlib quirc

  OpenCV modules:
    To be built: aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
    Disabled: java_bindings_generator python_bindings_generator python_tests world
    Disabled by dependency: python3
    Unavailable: alphamat cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv freetype hdf java julia matlab ovis python2 sfm viz
    Applications: perf_tests
    Documentation: NO
    Non-free algorithms: NO

  Windows RT support: NO

  GUI: WIN32UI
    Win32 UI: YES
    VTK support: NO

  Media I/O: 
    ZLib: build (ver 1.2.11)
    JPEG: build-libjpeg-turbo (ver 2.1.0-62)
    WEBP: build (ver encoder: 0x020f)
    PNG: build (ver 1.6.37)
    TIFF: build (ver 42 - 4.2.0)
    JPEG 2000: build (ver 2.4.0)
    OpenEXR: build (ver 2.3.0)
    HDR: YES
    SUNRASTER: YES
    PXM: YES
    PFM: YES

  Video I/O:
    DC1394: NO
    FFMPEG: YES (prebuilt binaries)
      avcodec: YES (58.134.100)
      avformat: YES (58.76.100)
      avutil: YES (56.70.100)
      swscale: YES (5.9.100)
      avresample: YES (4.0.0)
    GStreamer: NO
    Media Foundation: YES
      DXVA: YES

  Parallel framework: Concurrency

  Trace: YES (with Intel ITT)

  Other third-party libraries:
    Lapack: NO
    Eigen: NO
    Custom HAL: NO
    Protobuf: build (3.5.1)

  OpenCL: YES (NVD3D11)
    Include path: D:/build/opencv_453/3rdparty/include/opencl/1.2
    Link libraries: Dynamic load

  Python 3:
    Interpreter: C:/Users/User/AppData/Local/Programs/Python/Python39/python.exe (ver 3.9.6)
    Libraries: NO
    numpy: C:/Users/User/AppData/Local/Programs/Python/Python39/lib/site-packages/numpy/core/include (ver 1.21.2)
    install path: -

  Python (for build): C:/Users/User/AppData/Local/Programs/Python/Python39/python.exe

  Install to: D:/build/opencv_453/build/install
-----------------------------------------------------------------

Configuring done
Generating done

```

---

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 1:22pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/4 "2021-08-18T13:22:56Z")

</div>

> [@berak](#):
>
> please also see [the related answer here](https://forum.opencv.org/t/using-building-freetype-with-opencv-c/3424)

Also check this branch, it doesnt help me! I cant find a solution

---

<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:** [August 18, 2021, 1:39pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/5 "2021-08-18T13:39:43Z")

</div>

sorry, cant help any further ;(

but note, that upcoming opencv5 will have builtin support for true-type fonts  
(so this might no more be nessecary)

---

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 2:02pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/6 "2021-08-18T14:02:40Z")

</div>

Thank you anyway! Don’t you know the release date?

---

<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:** [August 18, 2021, 2:12pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/7 "2021-08-18T14:12:03Z")

</div>

> [@Alex\_Bilityuk](#):
>
> Don’t you know the release date?

idk, sorry. (christmas ?)

but [here’s the resp. pr](https://github.com/opencv/opencv/pull/18760)

---

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 2:29pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/8 "2021-08-18T14:29:40Z")

</div>

Does it mean it is already done or I misunderstood something? I mean the link you provided

---

<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:** [August 18, 2021, 2:33pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/9 "2021-08-18T14:33:55Z")

</div>

it is already done in _another branch_ (5.0 (aka ‘next’), not 4.5.3)  
you can [look at it here](https://github.com/opencv/opencv/tree/next)

---

<div class="post-metadata">

**Author:** ![Alex\_Bilityuk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/alex_bilityuk/32/2949_2.png) [@Alex\_Bilityuk](https://forum.opencv.org/u/Alex_Bilityuk)\
**Post date:** [August 18, 2021, 2:52pm UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/10 "2021-08-18T14:52:36Z")

</div>

It sounds great!!! Don’t you know how to use it? I mean is there any code example how to use new feture with truetype?

Sorry for my infinite questions

---

<div class="post-metadata">

**Author:** ![NullOne](https://avatars.discourse-cdn.com/v4/letter/n/a3d4f5/32.png) [@NullOne](https://forum.opencv.org/u/NullOne)\
**Post date:** [June 26, 2022, 12:20am UTC](https://forum.opencv.org/t/build-opencv-4-5-2-with-freetype-library/4825/11 "2022-06-26T00:20:18Z")

</div>

This question is pretty old, but I’ve got similar problem.  
These dependencies are checked by [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/). So freetype2 and harfbuzz should be found in the pkg-config search path.  
You can check if they are installed by these lines:

```auto
$ pkg-config harfbuzz --modversion
$ pkg-config freetype2 --modversion

```

So you need to install them by your OS package manager. I’m using Mac, so [brew](https://brew.sh/) helped me:

```auto
$ brew install freetype2
$ brew install harfbuzz

```
