maplibre-native: Error on cmake build: "error C2220: the following warning is treated as an error"
Describe the bug
Following the windows instructions, running cmake --build build results in errors that are based on warnings in this format:
error C2220: the following warning is treated as an error
warning C4018 ... signed/unsigned mismatch
The build can never complete with this error present, and addressing one would not fix the issues, as there are 100s of these errors.
To Reproduce
Steps to reproduce the behavior:
https://github.com/maplibre/maplibre-native/blob/main/platform/windows/README.md
Follow the instructions, you’ll run into the issue at cmake --build build
Expected behavior
Expecting it to build without errors.
Platform information (please complete the following information):
I’m running Windows 11 via Parallels on MacOS 13. Running cmake from Command Prompt.
Potential Solution
I made these changes to CMakeLists until I was able to get things running, probably not all these deletions are necessary, but the /WX one definitely is.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,10 +78,6 @@ target_compile_options(
-fsanitize-blacklist=${UBSAN_BLACKLIST}>
$<$<PLATFORM_ID:iOS>:-fembed-bitcode>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<OR:$<BOOL:${MLN_WITH_RTTI}>,$<CXX_COMPILER_ID:MSVC>>>>:-fno-rtti>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wall>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wshadow>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>>:-Wextra>
- $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<NOT:$<PLATFORM_ID:Windows>>,$<BOOL:${MLN_WITH_WERROR}>>:-Werror>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<PLATFORM_ID:Android>>:-Wno-error=tautological-constant-compare>
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=maybe-uninitialized>
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=return-type>
@@ -92,13 +88,11 @@ target_compile_options(
$<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MLN_WITH_QT}>>>:-Wno-error=unused-parameter>
$<$<AND:$<CXX_COMPILER_ID:AppleClang>,$<NOT:$<BOOL:${MLN_WITH_QT}>>>:-Wno-error=unused-property-ivar>
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
- $<$<CXX_COMPILER_ID:MSVC>:/WX> # all warnings as errors
$<$<CXX_COMPILER_ID:MSVC>:/EHsc> # exceptions
$<$<CXX_COMPILER_ID:MSVC>:/wd4068> # pragma
$<$<CXX_COMPILER_ID:MSVC>:/D_USE_MATH_DEFINES>
$<$<AND:$<NOT:$<CXX_COMPILER_ID:MSVC>>,$<PLATFORM_ID:Windows>>:-D_USE_MATH_DEFINES>
$<$<CXX_COMPILER_ID:MSVC>:/D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:/D_CRT_SECURE_NO_WARNINGS>
)
Curious how anyone is able to build with the configuration as is…
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 19 (7 by maintainers)
Solved the Open GL issue by using egl. So we’ve confirmed this is totally buildable from Windows 11 via Parallels on MacOS 13, you just need to make sure you’re using the right command prompt. I removed
WXand it worked, but not sure if that’s because something was cached…Thanks!
Nice! So the key points are: you need to set up your environment accordingly. As you were using a unusual setup, then this was a bit of challenge, but you figured it out nicely. Other key point is the build directory: is always recommended you delete this directory, since CMake caches some settings that need to change. So deleting it prevents it from keep old settings.
Thank you for sharing your experience. I will include it in the Windows README.md to guide future developers trying to follow the same steps you did.
Okay, maybe you need to reset your vcpkg. In the command window, do the command
git submodule foreach --recursive git clean -xfd. Also, you need to check if the/MDflag is still active. If it is, please remove it. Then try to build again.I forgot to tell you x86 (32-bit) is not currently supported. Are you emulating x86 or x86_64?
Furthermore, if you still have the Parallels VM (ARM), could you please create a file under
platform/windows/vendor/vcpkg-custom-tripletsnamedarm64-windows.cmake, with this contents?This will get rid of your
MD_DynamicReleaseerrors.If you want to continue to use the x86 VM, please change the file
x86-windows.cmakeunder the same directory to this:This will address the problem with the linkage. You don’t need to change anything else in the cmake files for now. Regarding the data type errors, I will check the files your log complains about, and thank you for providing the full log.
Maybe because ARM has some different configurations/include files than x86. With x86, the setup is very simple: Windows 10 or Windows 11, and Visual Studio 2022, either Community or Enterprise, it doesn’t affect the build.
Meanwhile I will try to emulate ARM with QEMU and check how it behaves.
I thought there was ARM builds for Windows, but apparently there are only ARM builds for Linux. I will check this also, and if it’s the case, update the CI files.