Repository: conan-io/conan-center-index

Issue:
[package] harfbuzz/2.7.2: Unresolved externals (missing libs) for visual studio
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **harfbuzz/2.7.2**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Visual studio 2019**
  * Conan version: **conan 1.35.0**
  * Python version: **Python 3.9.1**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
host profile
```
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MD
build_type=Release
[options]
[build_requires]
*: cmake/3.19.5, ninja/1.10.2
[env]
```

build profile
```
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MT
build_type=Release
[options]
msys2:packages="make,perl"
[build_requires]
*: cmake/3.19.5, ninja/1.10.2
blake2: mingw_installer/1.0@conan/stable, msys2/20190524
[env]
```

### Steps to reproduce (Include if Applicable)
Noticed this when consuming harfbuzz in Qt. Probably something in #5136 


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
[219/222] Linking CXX executable test\test_ui.exe
FAILED: test/test_ui.exe test/test_ui[1]_tests.cmake
cmd.exe /C "cd . && C:\Users\mjvk\.conan\data\cmake\3.19.5\_\_\package\0a420ff5c47119e668867cdb51baff0eca1fdb68\bin\cmake.exe -E vs_link_exe --intdir=test\CMakeFiles\test_ui.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MIB055~1\2019\BUILDT~1\VC\Tools\MSVC\1428~1.299\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\test_ui.rsp  /out:test\test_ui.exe /implib:test\test_ui.lib /pdb:test\test_ui.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console  && cmd.exe /C "cd /D C:\Soft_Dev\PSC_JLS_OCS\UI\build-vs2019\test && C:\Users\mjvk\.conan\data\cmake\3.19.5\_\_\package\0a420ff5c47119e668867cdb51baff0eca1fdb68\bin\cmake.exe -D TEST_TARGET=test_ui -D TEST_EXECUTABLE=C:/Soft_Dev/PSC_JLS_OCS/UI/build-vs2019/test/test_ui.exe -D TEST_EXECUTOR= -D TEST_WORKING_DIR=C:/Soft_Dev/PSC_JLS_OCS/UI/build-vs2019/test -D TEST_EXTRA_ARGS= -D TEST_PROPERTIES= -D TEST_PREFIX= -D TEST_SUFFIX= -D NO_PRETTY_TYPES=FALSE -D NO_PRETTY_VALUES=FALSE -D TEST_LIST=test_ui_TESTS -D CTEST_FILE=C:/Soft_Dev/PSC_JLS_OCS/UI/build-vs2019/test/test_ui[1]_tests.cmake -D TEST_DISCOVERY_TIMEOUT=30 -D TEST_XML_OUTPUT_DIR= -P C:/Users/mjvk/.conan/data/cmake/3.19.5/_/_/package/0a420ff5c47119e668867cdb51baff0eca1fdb68/share/cmake-3.19/Modules/GoogleTestAddTests.cmake""
LINK: command "C:\PROGRA~2\MIB055~1\2019\BUILDT~1\VC\Tools\MSVC\1428~1.299\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\test_ui.rsp /out:test\test_ui.exe /implib:test\test_ui.lib /pdb:test\test_ui.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console /MANIFEST /MANIFESTFILE:test\test_ui.exe.manifest" failed (exit code 1120) with the following output:
   Creating library test\test_ui.lib and object test\test_ui.exp
harfbuzz.lib(harfbuzz.obj) : error LNK2019: unresolved external symbol __imp_UuidCreate referenced in function "struct hb_blob_t * __cdecl _hb_rename_font(struct hb_blob_t *,wchar_t *)" (?_hb_rename_font@@YAPEAUhb_blob_t@@PEAU1@PEA_W@Z)
harfbuzz.lib(harfbuzz.obj) : error LNK2019: unresolved external symbol ScriptFreeCache referenced in function "public: struct hb_uniscribe_font_data_t * __cdecl hb_lazy_loader_t<struct hb_uniscribe_font_data_t,struct hb_shaper_lazy_loader_t<struct hb_font_t,2,struct hb_uniscribe_font_data_t>,struct hb_font_t,2,struct hb_uniscribe_font_data_t>::get_stored(void)const " (?get_stored@?$hb_lazy_loader_t@Uhb_uniscribe_font_data_t@@U?$hb_shaper_lazy_loader_t@Uhb_font_t@@$01Uhb_uniscribe_font_data_t@@@@Uhb_font_t@@$01U1@@@QEBAPEAUhb_uniscribe_font_data_t@@XZ)
harfbuzz.lib(harfbuzz.obj) : error LNK2019: unresolved external symbol ScriptItemize referenced in function "long __cdecl hb_ScriptItemizeOpenType(wchar_t const *,int,int,struct tag_SCRIPT_CONTROL const *,struct tag_SCRIPT_STATE const *,struct tag_SCRIPT_ITEM *,unsigned long *,int *)" (?hb_ScriptItemizeOpenType@@YAJPEB_WHHPEBUtag_SCRIPT_CONTROL@@PEBUtag_SCRIPT_STATE@@PEAUtag_SCRIPT_ITEM@@PEAKPEAH@Z)
harfbuzz.lib(harfbuzz.obj) : error LNK2019: unresolved external symbol ScriptShape referenced in function "long __cdecl hb_ScriptShapeOpenType(struct HDC__ *,void * *,struct tag_SCRIPT_ANALYSIS *,unsigned long,unsigned long,int *,struct textrange_properties * *,int,wchar_t const *,int,int,unsigned short *,struct script_charprop *,unsigned short *,struct script_glyphprop *,int *)" (?hb_ScriptShapeOpenType@@YAJPEAUHDC__@@PEAPEAXPEAUtag_SCRIPT_ANALYSIS@@KKPEAHPEAPEAUtextrange_properties@@HPEB_WHHPEAGPEAUscript_charprop@@6PEAUscript_glyphprop@@3@Z)
harfbuzz.lib(harfbuzz.obj) : error LNK2019: unresolved external symbol ScriptPlace referenced in function "long __cdecl hb_ScriptPlaceOpenType(struct HDC__ *,void * *,struct tag_SCRIPT_ANALYSIS *,unsigned long,unsigned long,int *,struct textrange_properties * *,int,wchar_t const *,unsigned short *,struct script_charprop *,int,unsigned short const *,struct script_glyphprop const *,int,int *,struct tagGOFFSET *,struct _ABC *)" (?hb_ScriptPlaceOpenType@@YAJPEAUHDC__@@PEAPEAXPEAUtag_SCRIPT_ANALYSIS@@KKPEAHPEAPEAUtextrange_properties@@HPEB_WPEAGPEAUscript_charprop@@HPEBGPEBUscript_glyphprop@@H3PEAUtagGOFFSET@@PEAU_ABC@@@Z)
test\test_ui.exe : fatal error LNK1120: 5 unresolved externals
```

</details>

### Recipe output
```
    Package_ID: d90f8e9faa56c14d892a469867e5f901ad8049d1
        [options]
            shared: False
            with_directwrite: True
            with_freetype: True
            with_gdi: True
            with_glib: True
            with_icu: False
            with_uniscribe: True
        [settings]
            arch: x86_64
            build_type: Release
            compiler: Visual Studio
            compiler.runtime: MD
            compiler.version: 16
            os: Windows
        [requires]
            brotli/1.0.9:3fb49604f9c2f729b85ba3115852006824e72cab
            bzip2/1.0.8:d16a91eadaaf5829b928b12d2f836ff7680d3df5
            freetype/2.10.4:27b2733304cef577b19f699fec3a5bdbefb36d16
            glib/2.68.0:39022ddb4abc5a55ae186ee8c99842984908fec8
            libelf/0.8.13:3fb49604f9c2f729b85ba3115852006824e72cab
            libffi/3.3:3fb49604f9c2f729b85ba3115852006824e72cab
            libgettext/0.20.1:b3e4dccd9a7572a5a29c77cc68475a955d494ef7
            libiconv/1.16:3fb49604f9c2f729b85ba3115852006824e72cab
            libpng/1.6.37:d140711d95cc16a85766a8fc3a551dfafe84cf63
            pcre/8.44:3f212c80aa6d2e609fef5fb7cb6dfc086d607220
            zlib/1.2.11:3fb49604f9c2f729b85ba3115852006824e72cab
        Outdated from recipe: False
```



Discussion:
I believe the following should be added to the `package_info` method:
```
if self.settings.os == "Windows":
    self.cpp_info.system_libs.extend(["usp10", "rpcrt4"])
```
please give a try and lemme know if it helps
usp10 and rpcrt4 do show up in the harfbuzz_SYSTEM_LIBS with the package as it is now. The search continues :-).
Turning off directwrite (which is the default in harfbuzz and thus in the old version) seems to fix it. Enabling only directwrite seems to fix it as well. I think you should only pick one backend.

Resolving patch:
diff --git a/recipes/harfbuzz/all/conanfile.py b/recipes/harfbuzz/all/conanfile.py
--- a/recipes/harfbuzz/all/conanfile.py
+++ b/recipes/harfbuzz/all/conanfile.py
@@ -29,7 +29,7 @@ class HarfbuzzConan(ConanFile):
         "with_glib": True,
         "with_gdi": True,
         "with_uniscribe": True,
-        "with_directwrite": True,
+        "with_directwrite": False
     }
 
     short_paths = True


Test patch: