Ask Your Question

Revision history [back]

Undefined freetype symbols when building openCV 3.2.0

openCV: 3.2.0

OS: Yosemite 10.10.5

compiler: Apple LLVM version 7.0.2 (clang-700.1.81)

I built openCV 3.2.0 successfully, but then I found out that I needed ffmpeg support. I installed ffmpeg with homebrew, and when I tried to build openCV again, the build failed because of undefined symbols in freetype libraries. I then tried to build openCV again without ffmpeg, and the build failed with the same errors. Before I installed ffmpeg I ran brew upgrade and I saw that it upgraded freetype, so this may be the source of the problem, but if so I don't know what to do about it. Here's the command I'm running

PYTHON3_DIR=`python3-config --prefix` # Get python 3 path
VIRTUAL_ENV=`python3-config --prefix`
-D PYTHON3_PACKAGES_PATH=$VIRTUAL_ENV/lib/python3.5/site-packages \
-D PYTHON3_INCLUDE_DIR=$VIRTUAL_ENV/include/python3.5m \
-D PYTHON3_LIBRARY=$PYTHON3_DIR/lib/libpython3.5m.dylib \
-D PYTHON3_NUMPY_INCLUDE_DIRS=$VIRTUAL_ENV/lib/python3.5/site-packages/numpy/core/include/ \
-D BUILD_opencv_python3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..

This produces no errors, but when I run make I get

[ 26%] Building CXX object modules/freetype/CMakeFiles/opencv_freetype.dir/src/freetype.cpp.o
[ 26%] Linking CXX shared library ../../lib/libopencv_freetype.dylib
Undefined symbols for architecture x86_64:
  "_FT_Done_Face", referenced from:
      cv::freetype::FreeType2Impl::~FreeType2Impl() in freetype.cpp.o
      cv::freetype::FreeType2Impl::loadFontData(cv::String, int) in freetype.cpp.o
  "_FT_Done_FreeType", referenced from:
      cv::freetype::FreeType2Impl::~FreeType2Impl() in freetype.cpp.o
  "_FT_Init_FreeType", referenced from:
      cv::freetype::FreeType2Impl::FreeType2Impl() in freetype.cpp.o
      cv::freetype::FreeType2Impl::FreeType2Impl() in freetype.cpp.o
      cv::freetype::createFreeType2() in freetype.cpp.o

and a bunch of other missing symbols. When I run nm freetype.cpp.o those symbols are listed as undefined all right, but I can successfully install openCV 3.2.0 (with ffmpeg support) on Ubuntu 16.04 using gcc 5.4, and those same symbols are undefined in freetype.cpp.o, so I guess it's trying to link them from another file, but I have no clue which.

I really need installed it on the Mac. I only installed in on Ubuntu as a temporary stopgap. Can you give me any advice?