Closed kilbouri closed 1 year ago
I figured out how to build the library with CMake directly (just the library, not our Flutter app). Builds completely fine (as I expected) once I copied the recommended settings into the provided CMakeLists.txt:
set(use_mqtt ON CACHE BOOL "Set mqtt on" FORCE)
set(skip_samples ON CACHE BOOL "Set slip_samples on" FORCE)
set(BUILD_TESTING OFF CACHE BOOL "Set BUILD_TESTING off" FORCE)
This tells me its an issue with my CMake configuration, but I don't know what. Any help in that department would be much appreciated.
C:\digitallab-libraries\iothub_device\example\windows\flutter\ephemeral\.plugin_symlinks\iothub_device\windows\azure-iot-sdk-c\c-utility\src\consolelogger.c(71,151): warning C4133: 'function': incompatible types - from 'char [260]' to 'LPWSTR' [C:\digitallab-libraries\iothub_device\example\build\windows\plugins\iothub_device\out\c-utility\aziotsharedutil.vcxproj]
LPWSTR being either a wide char or char depending on whether UNICODE is defined in your project. Try and undefine UNICODE to use the multibyte(ANSI) version.
That fixes the warnings, but leaves me with a couple questions:
This SDK only supports multi-byte. This is purely controlled by the compiler UNICODE define. You can create a library for the IoT SDK files that a cmake creates a lib and override the UNICODE compiler define, and them import that lib into your Unicode application. there
you can remove the unicode directive in the SDK with the following cmake changes
# Add Azure IoT SDK C
remove_definitions(-DUNICODE)
add_subdirectory(azure-iot-sdk-c out)
add_definitions(-DUNICODE)
Something is up, I can't seem to remove the definitions. Closing this issue because its unrelated to the SDK at this point. Thank you very much for your help @ericwol-msft !
Development Machine, OS, Compiler (and Other Relevant Toolchain Info)
Windows 10 Machine
Flutter 3.7.0 MSVC 19.34.31937 CMake 3.24.202208181-MSVC_2
SDK Version (Please Give Commit SHA if Manually Compiling)
Release LTS_01_2023_Ref01
Protocol
MQTT
Describe the Bug
Compiling with Flutter's CMake fails. See CMakeLists.txt and logs below:
CMakeLists.txt
Error logs (from
flutter run -d windows
):It is possible this issue is related to #2436, but I don't know enough C++/CMake to be sure.