maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.06k stars 310 forks source link

Windows CMake VS build fails in vendor/icu #2961

Open clinthidinger opened 1 week ago

clinthidinger commented 1 week ago

Describe the bug Windows CMake build with Visual Studio fails with unresolved external symbol errors for UnicodeString:

`Building Custom Rule C:/Users/xxx/Documents/code/maplibre-native/CMakeLists.txt
mbgl-vendor-icu.lib(uinvchar.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: int __cdecl icu_61::UnicodeString::length(void)const " (__imp_?l
ength@UnicodeString@icu_61@@QEBAHXZ) referenced in function uprv_isInvariantUnicodeString [C:\Users\xxx\maplibre-native\
build\bin\mbgl-cache.vcxproj]
mbgl-vendor-icu.lib(uinvchar.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: char16_t const * __cdecl icu_61::UnicodeString::getBuffer(void)c
onst " (__imp_?getBuffer@UnicodeString@icu_61@@QEBAPEB_SXZ) referenced in function uprv_isInvariantUnicodeString [C:\Users\xxx\maplibre-native\build\bin\mbgl-cache.vcxproj]
C:\Users\xxx\Documents\code\maplibre-native\build\bin\Release\mbgl-cache.exe : fatal error LNK1120: 2 unresolved externals [C:\Users\xxx\Documents\code\maplibre-native\build\bin\mbgl-cache.vcxproj]`

To Reproduce Steps to reproduce the behavior:

  1. Run Cmake on windows for the project
  2. cmake --build . --config Release

Expected behavior A successful build.

Explanation UnicodeString::length() is defined here: https://github.com/maplibre/maplibre-native/blob/main/vendor/icu/include/unicode/unistr.h#L3906

unistr.h is being included in univchar.h here: https://github.com/maplibre/maplibre-native/blob/main/vendor/icu/src/uinvchar.h#L27

I have not looked into a proper fix.

I hacked the problem by commenting out uprv_isInvariantUnicodeString() in maplibre-native/vendor/icu/src/uinvchar.h since it is not used. It successfully built after I did that.

Platform information (please complete the following information):

MBGL_USE_BUILTIN_ICU was not explicitly set.

louwers commented 1 week ago

Maybe @tdcosta100 knows how to resolve this

tdcosta100 commented 1 week ago

I need to check the vcpkg repository. I updated it some days ago, but it was reversed by someone by mistake. Could you go to vcpkg directory:

cd platform\windows\vendor\vcpkg

And then do the commands:

git fetch --all
git checkout 2024.09.30

Then try to build again. If it works, the problem is the vcpkg version.

clinthidinger commented 6 days ago

MINGW64 ~/Documents/code/maplibre_test/maplibre-native/platform/windows/vendor/vcpkg (main) $ git checkout 2024.09.30 error: pathspec '2024.09.30' did not match any file(s) known to git

I did the fetch. Am I missing a step?

tdcosta100 commented 6 days ago

No, my instruction was wrong, sorry. Please try again with this:

git checkout tags/2024.09.30
louwers commented 6 days ago

Should be fixed in main now: https://github.com/maplibre/maplibre-native/pull/2966

tdcosta100 commented 6 days ago

Thanks!

clinthidinger commented 2 hours ago

@tdcosta100 , I was able to checkout tags/2024.09.30 under platform/windows/vendor/vcpkg. When I ran the build, I got the same error.

tdcosta100 commented 1 hour ago

Okay, so the problem is elsewhere. Are you using MinGW to build the project?