meganz / sdk

MEGA C++ SDK
BSD 2-Clause "Simplified" License
1.33k stars 504 forks source link

Errors while building the Windows SDK (x86): "error C2220: the following warning is treated as an error" #2581

Open vlad-mal opened 3 years ago

vlad-mal commented 3 years ago

Hello.

OS: Win10 x64 Pro, IDE: Microsoft Visual Studio Community Edition.

When building SDK for Windows (x86), using the method described in the Read.me file (https://github.com/meganz/sdk/blob/master/README.md):

cmake -DTRIPLET=x86-windows-mega-staticdev -DEXTRA_ARGS="-DUSE_PDFIUM=0" -P build_from_scratch.cmake

All 3rd-party components are built without problems, however, when building the mega sdk itself, errors appear: error C2220: the following warning is treated as an error ... followed by warnings, mainly related to comparing signed and unsigned integer types, for example warning C4018: '> =': signed / unsigned mismatch

Analysis showed that the crash is due to the fact that mega sdk projects are built with the /W4 and /WX compiler switches. In previous versions of mega sdk, the assembly was performed with the keys /W3 and /WX-. Fix please.

Thank you. Best regards, Vladimir Malinovsky.

vlad-mal commented 3 years ago

OK I understood. And so it was conceived. The file \sdk\CMakeLists.txt contains the following lines:

 # warnings as errors, just for windows builds, as warnings keep creeping in. Best if we address them once in the original MRs.
 set (CMAKE_CXX_FLAGS_DEBUG "$ {CMAKE_CXX_FLAGS_DEBUG} /WX")

That is, you just need to comment out the second line: # set (CMAKE_CXX_FLAGS_DEBUG "$ {CMAKE_CXX_FLAGS_DEBUG} /WX") Could have warned, because I spent the whole evening looking for an error. Thank you.

mattw-mega commented 3 years ago

Thanks for letting us know, most of our automated processes are on x64 nowadays. In the meantime, as you discovered, you can easily switch /WX off. thanks