Skip to content

Build fails on gcc>6 on Ubuntu 20.04 with Freetype include paths #26233

@zachlowry

Description

@zachlowry

System Information

OpenCV python version: 4.10.0
Operating System / Platform: Ubuntu 20.04
Python version: 3.8.10

Detailed description

OpenCV 4.10 fails to build on Ubuntu 20.04 with Freetype enabled in the GAPI module. The build system fails to find ft2build.h, which is located in /usr/include/freetype2. This path is discovered in the call to ocv_check_modules in init.cmake, but the directory "/usr/include" is added to the end of the list of paths. This causes the gcc6 bug workaround in ocv_target_include_directories to be hit because the string representation of the array containing the Freetype2 include paths ends in ";/usr/include". This issue seems to affect other libraries that are discovered within the build system that use ocv_check_modules as well. I have a branch that I will attach that resolves this issue by moving the check for "/usr/include" to within the loop that iterates over the directories to include.

  In file included from /tmp/pip-req-build-ifckk0ry/opencv/modules/gapi/src/backends/render/ft_render.cpp:12:
  /tmp/pip-req-build-ifckk0ry/opencv/modules/gapi/src/backends/render/ft_render_priv.hpp:15:10: fatal error: ft2build.h: No such file or directory
     15 | #include <ft2build.h>
        |          ^~~~~~~~~~~~
  compilation terminated.
  make[2]: *** [modules/gapi/CMakeFiles/opencv_gapi.dir/build.make:1196: modules/gapi/CMakeFiles/opencv_gapi.dir/src/backends/render/ft_render.cpp.o] Error 1
  make[2]: *** Waiting for unfinished jobs....
  make[2]: Leaving directory '/tmp/pip-req-build-ifckk0ry/_skbuild/linux-x86_64-3.8/cmake-build'
  make[1]: *** [CMakeFiles/Makefile2:5547: modules/gapi/CMakeFiles/opencv_gapi.dir/all] Error 2
  make[1]: *** Waiting for unfinished jobs....

Steps to reproduce

attempt to build OpenCV 4.x on Ubuntu 20.04 with Freetype installed

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions