Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol for freetype #2239

Open
xkszltl opened this issue Aug 24, 2019 · 4 comments
Open

Undefined symbol for freetype #2239

xkszltl opened this issue Aug 24, 2019 · 4 comments

Comments

@xkszltl
Copy link

xkszltl commented Aug 24, 2019

System information (version)
  • OpenCV => 4.1.1
  • Operating System / Platform => Win10
  • Compiler => VS2019/cmake/ninja
Detailed description

We compile OpenCV with freetype module and recently start to get build failures with unresolved external symbols when we try to update to the latest release.

Since there're updates in both freetype and OpenCV, I'm not sure which one is the root cause.

Note that we compile freetype/harfbuzz/OpenCV from source by script.
Our last update was in mid Jun, 2019.
So the previous working version should be freetype 2.10.0 + OpenCV 4.1.0.
There's no change in our build script and we always pull the latest release version to build.

Current latest of freetype is 2.10.1.
I also tried freetype 2.10.0+opencv 4.1.1 but got the same error.

Log attached:

[1/2] Linking CXX shared library bin\opencv_freetype411.dll
FAILED: bin/opencv_freetype411.dll lib/opencv_freetype411.lib
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --intdir=modules\freetype\CMakeFiles\opencv_freetype.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100162~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100162~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~4\2019\ENTERP~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\link.exe /nologo modules\freetype\CMakeFiles\opencv_freetype.dir\src\freetype.cpp.obj modules\freetype\CMakeFiles\opencv_freetype.dir\vs_version.rc.res modules\freetype\CMakeFiles\opencv_freetype.dir\opencv_freetype_main.cpp.obj  /out:bin\opencv_freetype411.dll /implib:lib\opencv_freetype411.lib /pdb:pdb\opencv_freetype411.pdb /dll /version:4.1 /DEBUG:FASTLINK /LTCG:incremental  /INCREMENTAL:NO  /debug /NODEFAULTLIB:libc /DEBUG  lib\opencv_imgproc411.lib opengl32.lib glu32.lib 3rdparty\lib\ippiw.lib 3rdparty\ippicv\ippicv_win\icv\lib\intel64\ippicvmt.lib lib\opencv_core411.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  && cd ."
LINK: command "C:\PROGRA~2\MICROS~4\2019\ENTERP~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\link.exe /nologo modules\freetype\CMakeFiles\opencv_freetype.dir\src\freetype.cpp.obj modules\freetype\CMakeFiles\opencv_freetype.dir\vs_version.rc.res modules\freetype\CMakeFiles\opencv_freetype.dir\opencv_freetype_main.cpp.obj /out:bin\opencv_freetype411.dll /implib:lib\opencv_freetype411.lib /pdb:pdb\opencv_freetype411.pdb /dll /version:4.1 /DEBUG:FASTLINK /LTCG:incremental /INCREMENTAL:NO /debug /NODEFAULTLIB:libc /DEBUG lib\opencv_imgproc411.lib opengl32.lib glu32.lib 3rdparty\lib\ippiw.lib 3rdparty\ippicv\ippicv_win\icv\lib\intel64\ippicvmt.lib lib\opencv_core411.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:bin\opencv_freetype411.dll.manifest" failed (exit code 1120) with the following output:
   Creating library lib\opencv_freetype411.lib and object lib\opencv_freetype411.exp
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_buffer_destroy
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Outline_Decompose
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_buffer_create
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_buffer_get_glyph_infos
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_font_destroy
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_New_Face
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Done_FreeType
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Done_Face
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Outline_Transform
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_shape
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_buffer_guess_segment_properties
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Init_FreeType
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Outline_Get_BBox
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Outline_Translate
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Render_Glyph
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_buffer_add_utf8
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Load_Glyph
freetype.cpp.obj : error LNK2001: unresolved external symbol hb_ft_font_create
freetype.cpp.obj : error LNK2001: unresolved external symbol FT_Set_Pixel_Sizes
bin\opencv_freetype411.dll : fatal error LNK1120: 19 unresolved externals
ninja: build stopped: subcommand failed.
@xkszltl
Copy link
Author

xkszltl commented Aug 24, 2019

Freetype 2.10.1 (latest) + OpenCV 4.1.0 is working.

@crackwitz
Copy link

crackwitz commented Sep 26, 2019

opencv 4.1.1 changed something in the CMakeFiles.txt

before I could only get opencv to use freetype with the line find_package(Freetype) added (win7/win10). that's the case now as well.

perhaps the ocv_check_modules macro needs to be extended for this?

related: #1497

@xkszltl
Copy link
Author

xkszltl commented Apr 28, 2020

Issue still exists in 4.3.0.
Anyone working on the fix?

@xkszltl
Copy link
Author

xkszltl commented May 2, 2020

Worked around by setting:

FREETYPE_FOUND=ON
FREETYPE_INCLUDE_DIRS=...
FREETYPE_LIBRARIES=...
FREETYPE_LINK_LIBRARIES=...
FREETYPE_LINK_LIBRARIES_XXXXX=ON
HARFBUZZ_FOUND=ON
HARFBUZZ_INCLUDE_DIRS=...
HARFBUZZ_LIBRARIES=...
HARFBUZZ_LINK_LIBRARIES=...
HARFBUZZ_LINK_LIBRARIES_XXXXX=ON

It's important to set <PKG>_LINK_LIBRARIES and <PKG>_LINK_LIBRARIES_XXXXX to avoid wiping out <PKG>_LIBRARIES:
https://github.com/opencv/opencv/blob/01b2c5a77ca6dbef3baef24ebc0a5984579231d9/cmake/OpenCVUtils.cmake#L823-L825

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants