eclipse/paho.mqtt.c

Compile Issue with OS Defines in VS Code

nicofer00 opened this issue · 4 comments

#if !defined(_WINDOWS)

At first, trying to build on Windows 10 machine with OpenSSL variables passed in. Testing is enabled by default but would cause the build to fail at compile time. Probably should also check for _WIN32 because I don't think _WINDOWS was being defined. When I added it in manually to the CMakeLists.txt then it could successfully compile. I also tried alternatively adding checks to the test files to guard windows compilation better.

image

I made changes to make the statements #if !defined(_WINDOWS) && !defined(_WIN32) && !defined(_WIN64) and #if defined(_WINDOWS) || defined(_WIN32) || defined(_WIN64) which successfully compiled and ran the tests for me.

Current work around is to skip it in my compilation with the command:
cmake -G "Unix Makefiles" -B build -DCMAKE_INSTALL_PREFIX=/ -DPAHO_BUILD_STATIC=TRUE -DPAHO_ENABLE_TESTING=FALSE -DPAHO_WITH_SSL=TRUE -DOPENSSL_ROOT_DIR="C:\Program Files\OpenSSL-Win64\"

then:
cmake --build build/ --target install

which worked as well.

paho_issue_1481.txt

here is a diff of changes that allowed me to successfully compile with tests enabled in windows. Probably not the best way to go about it but just to show it works...

I have the following Preprocessor Definitions

%(PreprocessorDefinitions);WIN32;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;CMAKE_INTDIR="Debug"

Ok so VS Code configuration thing, I guess! The extra compile guards could take away the need for that manual step if that's desirable in the future, but this makes sense to me.