Hi guys I have installed paho-mqtt via vcpkg which was successful:
> -- Performing post-build validation
> -- Performing post-build validation done
> Building package paho-mqtt:x86-windows... done
> Installing package paho-mqtt:x86-windows...
> Installing package paho-mqtt:x86-windows... done
I have then done vcpkg integrate install which appeared to be successful as well, but when including the following in a c++ application in VS 2017:
#include "mqtt/async_client.h"
It gives me errors about not being able to find MQTTAsync.h any ideas please. TIA
@AdamMiltonBarker oculd you try just async_client.h without the mqtt.
@AdamMiltonBarker see https://github.com/eclipse/paho.mqtt.c/blob/master/src/samples/MQTTAsync_publish.c#L20
Thanks for the quick reply, using just async_client.h
> cannot open source file "async_client.h"
> Cannot open include file: 'async_client.h': No such file or directory
>
I had already tried #include "MQTTAsync.h" which did not work I tried the above due to the C++ library example showing that.
Using #include "MQTTAsync.h"
cannot open source file "MQTTAsync.h"
Cannot open include file: 'MQTTAsync.h': No such file or directory
Here is what I am getting if I install

That is exactly what I got also, however it does not work in Visual Studio C++ app.
vcpkg install paho-mqtt
The following packages will be built and installed:
paho-mqtt:x86-windows
Building package paho-mqtt:x86-windows...
-- CURRENT_INSTALLED_DIR=D:/Installations/vcpkg/installed/x86-windows
-- DOWNLOADS=D:/Installations/vcpkg/downloads
-- CURRENT_PACKAGES_DIR=D:/Installations/vcpkg/packages/paho-mqtt_x86-windows
-- CURRENT_BUILDTREES_DIR=D:/Installations/vcpkg/buildtrees/paho-mqtt
-- CURRENT_PORT_DIR=D:/Installations/vcpkg/ports/paho-mqtt/.
-- Downloading https://github.com/eclipse/paho.mqtt.c/archive/v1.2.0.tar.gz...
-- Downloading https://github.com/eclipse/paho.mqtt.c/archive/v1.2.0.tar.gz... OK
-- Testing integrity of downloaded file...
-- Testing integrity of downloaded file... OK
-- Extracting source D:/Installations/vcpkg/downloads/eclipse-paho.mqtt.c-v1.2.0.tar.gz
-- Extracting done
-- Applying patch D:/Installations/vcpkg/ports/paho-mqtt/disable_tests.patch
-- Applying patch D:/Installations/vcpkg/ports/paho-mqtt/disable_tests.patch done
-- Applying patch D:/Installations/vcpkg/ports/paho-mqtt/remove_compiler_options.patch
-- Applying patch D:/Installations/vcpkg/ports/paho-mqtt/remove_compiler_options.patch done
-- Configuring x86-windows-rel
-- Configuring x86-windows-rel done
-- Configuring x86-windows-dbg
-- Configuring x86-windows-dbg done
-- Build x86-windows-rel
-- Build x86-windows-rel done
-- Build x86-windows-dbg
-- Build x86-windows-dbg done
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/bin/paho-mqtt3a.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/bin/paho-mqtt3as.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/bin/paho-mqtt3c.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/bin/paho-mqtt3cs.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/lib/paho-mqtt3a.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/lib/paho-mqtt3as.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/lib/paho-mqtt3c.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/lib/paho-mqtt3cs.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/bin/paho-mqtt3a.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/bin/paho-mqtt3as.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/bin/paho-mqtt3c.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/bin/paho-mqtt3cs.dll
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/lib/paho-mqtt3a.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/lib/paho-mqtt3as.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/lib/paho-mqtt3c.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/debug/lib/paho-mqtt3cs.lib
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Clients.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Heap.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/LinkedList.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Log.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTAsync.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTClient.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTClientPersistence.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTPacket.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTPacketOut.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTPersistence.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTPersistenceDefault.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTProtocol.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTProtocolClient.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/MQTTProtocolOut.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Messages.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/SSLSocket.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Socket.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/SocketBuffer.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/StackTrace.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Thread.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/Tree.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/include/utf-8.h
-- Installing: D:/Installations/vcpkg/packages/paho-mqtt_x86-windows/share/paho-mqtt/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package paho-mqtt:x86-windows... done
Installing package paho-mqtt:x86-windows...
Installing package paho-mqtt:x86-windows... done
cannot open source file "async_client.h"
Cannot open include file: 'async_client.h': No such file or directory
cannot open source file "MQTTAsync.h"
Cannot open include file: 'MQTTAsync.h': No such file or directory

I just copied that file on my machine and it seemed to build fine
Edit:
One thing to note is when building x86 you should have installed it like vcpkg install paho-mqtt
When building x64 you should have vcpkg install paho-mqtt:x64-windows. If you try x86 when you have only installed x64 you might come across problems.
vcpkg install paho-mqtt:x64-windows that may be it I will try that, thanks. I was not aware of that, I installed by vcpkg install paho-mqtt but the project is 64
Now I have a whole load of errors about storage type :(
this declaration has no storage class or type specifier d:\Installations\vcpkg\installedx64-windows\include\MQTTAsync.h
expected a ';'
d:\Installations\vcpkg\installedx64-windows\include\MQTTAsync.h
I see. Can you change this to https://github.com/eclipse/paho.mqtt.c/blob/94cc8f431c7746d23dbd015c643e1f9c5cbbbef3/src/MQTTAsync.h#L95 to defined(_WIN32) || defined(WIN64)
Edit:
I will add a pull request soon
Also cannot open unistd.h, Severity Code Description Project File Line Suppression State
Error (active) E0020 identifier "MQTTAsync_connect" is undefined TiaCoreCV d:\Transporter\PROGRAMMING_Artificial_Intelligence__TiaR\TiaRCore\TiaRCoreCV\TiaCoreCV\TiaCoreCV\TiaCoreCV.cpp 77
The list goes on, I tried just adding include to my existing code which came up with above errors amongst others then I tried the full code and it is worse.
@AdamMiltonBarker See my comment above
Will do thanks just doing it now.
Updated to:
#if defined(_WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
No change at all.
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(584): error C2061: syntax error: identifier 'MQTTAsync_createOptions'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C2143: syntax error: missing ';' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C2238: unexpected token(s) preceding ';'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C2143: syntax error: missing ';' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C2238: unexpected token(s) preceding ';'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2143: syntax error: missing ',' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2143: syntax error: missing ',' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2065: 'MQTTAsync_traceCallback': undeclared identifier
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2065: 'callback': undeclared identifier
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2182: 'MQTTAsync_setTraceCallback': illegal use of type 'void'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C2146: syntax error: missing ';' before identifier 'MQTTAsync_nameValue'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\excpt.h(49): error C2143: syntax error: missing ';' before '__cdecl'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(52): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(54): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(56): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(161): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(162): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(163): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(164): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(165): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(168): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(169): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(167): error C2065: 'ULONG_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(167): error C2146: syntax error: missing ')' before identifier 'h'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(176): error C2065: 'LONG_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(176): error C2146: syntax error: missing ')' before identifier 'h'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(185): error C2065: 'UINT_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(185): error C2146: syntax error: missing ')' before identifier 'h'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(195): error C2065: 'INT_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(195): error C2146: syntax error: missing ')' before identifier 'h'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(205): error C2065: 'ULONG_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(205): error C2146: syntax error: missing ')' before identifier 'p'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(214): error C2065: 'UINT_PTR': undeclared identifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(214): error C2146: syntax error: missing ')' before identifier 'p'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\basetsd.h(214): fatal error C1003: error count exceeds 100; stopping compilation
1>Done building project "TiaCoreCV.vcxproj" -- FAILED.
Try this
#ifdef _WIN32
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
#include <OsWrapper.h> is not needed. Its for linux users
Edit: Make sure you update
@AdamMiltonBarker Just wondering if you managed to fix the issue
Hi mate no not managed to, just updated the above files in the location:
D:\Installations\vcpkg\packages\paho-mqtt_x64-windows\include
And no change again.
@AdamMiltonBarker Can you please test the following snippet
/*******************************************************************************
* Copyright (c) 2012, 2013 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial contribution
*******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MQTTAsync.h"
#if !defined(_WIN32)
#include <unistd.h>
#else
#include <windows.h>
#endif
#define ADDRESS "tcp://m2m.eclipse.org:1883"
#define CLIENTID "ExampleClientPub"
#define TOPIC "MQTT Examples"
#define PAYLOAD "Hello World!"
#define QOS 1
#define TIMEOUT 10000L
volatile MQTTAsync_token deliveredtoken;
int finished = 0;
void connlost(void *context, char *cause)
{
MQTTAsync client = (MQTTAsync)context;
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
int rc;
printf("\nConnection lost\n");
printf(" cause: %s\n", cause);
printf("Reconnecting\n");
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
finished = 1;
}
}
void onDisconnect(void* context, MQTTAsync_successData* response)
{
printf("Successful disconnection\n");
finished = 1;
}
void onSend(void* context, MQTTAsync_successData* response)
{
MQTTAsync client = (MQTTAsync)context;
MQTTAsync_disconnectOptions opts = MQTTAsync_disconnectOptions_initializer;
int rc;
printf("Message with token value %d delivery confirmed\n", response->token);
opts.onSuccess = onDisconnect;
opts.context = client;
if ((rc = MQTTAsync_disconnect(client, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
exit(EXIT_FAILURE);
}
}
void onConnectFailure(void* context, MQTTAsync_failureData* response)
{
printf("Connect failed, rc %d\n", response ? response->code : 0);
finished = 1;
}
void onConnect(void* context, MQTTAsync_successData* response)
{
MQTTAsync client = (MQTTAsync)context;
MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
int rc;
printf("Successful connection\n");
opts.onSuccess = onSend;
opts.context = client;
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
pubmsg.qos = QOS;
pubmsg.retained = 0;
deliveredtoken = 0;
if ((rc = MQTTAsync_sendMessage(client, TOPIC, &pubmsg, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
exit(EXIT_FAILURE);
}
}
int main(int argc, char* argv[])
{
MQTTAsync client;
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
int rc;
MQTTAsync_create(&client, ADDRESS, CLIENTID, MQTTCLIENT_PERSISTENCE_NONE, NULL);
MQTTAsync_setCallbacks(client, NULL, connlost, NULL, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.onSuccess = onConnect;
conn_opts.onFailure = onConnectFailure;
conn_opts.context = client;
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
exit(EXIT_FAILURE);
}
printf("Waiting for publication of %s\n"
"on topic %s for client with ClientID: %s\n",
PAYLOAD, TOPIC, CLIENTID);
while (!finished)
#if defined(WIN32)
Sleep(100);
#else
usleep(10000L);
#endif
MQTTAsync_destroy(&client);
return rc;
}
@AdamMiltonBarker create a simple project in VS and user the above
Thanks I am in a console app as that is what I need it for and using the code above:
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(510): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(521): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(565): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(583): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(584): error C2061: syntax error: identifier 'MQTTAsync_createOptions'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C2143: syntax error: missing ';' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(739): error C2238: unexpected token(s) preceding ';'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C2143: syntax error: missing ';' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(764): error C2238: unexpected token(s) preceding ';'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(848): error C2143: syntax error: missing ',' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(903): error C2143: syntax error: missing ',' before '*'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(913): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(930): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(950): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(964): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(978): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(999): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1018): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1039): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1050): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1063): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1076): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1086): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1095): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1116): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2448: '__attribute__': function-style initializer appears to be a function definition
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2065: 'MQTTAsync_traceCallback': undeclared identifier
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2065: 'callback': undeclared identifier
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1135): error C2182: 'MQTTAsync_setTraceCallback': illegal use of type 'void'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C3861: 'visibility': identifier not found
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C2374: '__attribute__': redefinition; multiple initialization
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(494): note: see declaration of '__attribute__'
1>D:\Installations\vcpkg\installed\x64-windows\include\MQTTAsync.h(1150): error C2146: syntax error: missing ';' before identifier 'MQTTAsync_nameValue'
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11.25503\include\excpt.h(49): error C2143: syntax error: missing ';' before '__cdecl'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(52): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(54): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(56): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(161): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(162): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(163): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(164): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(165): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(168): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(169): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(171): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\minwindef.h(172): error C2143: syntax error: missing ';' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\ctype.h(183): error C3861: '_isctype_l': identifier not found
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(588): error C3646: 'Group': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(588): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(589): error C3646: 'Number': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(589): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(590): error C3646: 'Reserved': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(590): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(600): error C3646: 'Group': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(600): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(601): error C3646: 'Reserved': unknown override specifier
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(601): error C2143: syntax error: missing ',' before '['
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(601): error C2143: syntax error: missing ')' before ';'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(601): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(641): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(641): error C2146: syntax error: missing ';' before identifier 'FCHAR'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um\winnt.h(641): fatal error C1003: error count exceeds 100; stopping compilation
1>Done building project "TiaCoreCV.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
OK I created a new console app and it worked, these are the includes in the project I need it, the OpenCV is a custom version from the Intel Computer Vision SDK and also I use the Realsense SDK, can you see anything that would be causing this, I really need to get MQTT in this project:
#include "stdafx.h"
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/pvl.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
#include <time.h>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <pxcsensemanager.h>
@AdamMiltonBarker The problem is
#if defined(_WIN32) || defined(_WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
Because of it you are being directed to #define DLLExport __attribute__ ((visibility ("default"))) hence all those errors. __attribute__ ((visibility ("default"))) is available on gcc/g++ and not MSVC. Can you please cross check whether the file MQTTAsync.h and MQTTClient.h are defined as the above.
EDIT
If you look at the log you send above. The issue starts at line 494.

Project properties:
Includes:
C:\Program Files (x86)\Intel\RSSDK\sample\common\include
C:\Intel\CV SDK\1.0\opencv\include
C:\Program Files (x86)\Intel\RSSDK\include
Linker:
C:\Program Files (x86)\Intel\RSSDK\sample\common\libx64\v140
C:\Program Files (x86)\Intel\RSSDK\libx64
C:\Intel\CV SDK\1.0\opencvx64\vc14\lib
opencv_pvl330.lib
opencv_world330.lib
libpxc_d.lib
libpxcutils_d.lib
Have not come across any issues with included libraries like this. Any suggestions guys ?
Hi mate I already confirmed to you that I had made those amendments, the issue is only happening in a project with the above includes etc, even if I replace the code entirely it is still erroring but in a new project it works ok.
@ras0219 @alexkaratarakis thoughts?
Sorry they were set as the last instructions you gave:
#if def _WIN32
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
Setting them as you have suggested now, still makes no difference. Both the MQTTAsync and MQTTClient files in this directory:
D:\Installations\vcpkg\packages\paho-mqtt_x64-windows\include
Match this:
#if defined(_WIN32) || defined(_WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
@AdamMiltonBarker Sorry miscommunication on my part . You are supposed to edit the files in
D:\Installations\vcpkg\installed\x64-windows\include
ok thanks will try now
That seems to have it done but now it is telling me it cant open the solution exe, but those errors seem to have gone I need to test the full code still but looking good :) Any idea on not being able to access the exe when building ?
@AdamMiltonBarker Good :). I have no idea what causes it. That might be might be a question for msft ses @ras0219-msft @alexkaratarakis
OK thanks stuck on that at the moment but I think you solved my issue with Paho thanks for all the help mate.
@AdamMiltonBarker glad I could help
@atkawa7 the issue was resolved by restarting and the build was successful, could I leave this open till I can confirm everything works, and by the way, VCPKG actually saved my life if this works :) I struggled for days to try and get Paho installed and was not able to, great idea.
@AdamMiltonBarker Great to hear it all worked out.
@atkawa7 do you know of any examples for using this with SSL, including SSLSocket.h crashes the app.
@AdamMiltonBarker See https://github.com/eclipse/paho.mqtt.c/blob/master/test/test3.c
Hmm getting return code -13, was not even aware they went up that far 6-255 reserved for future use. Server is not even touched no log on the broker of getting a connection attempt
Anyway will close this off now as it related to Paho, thanks for the help again mate.
I had some feedback from Paho, they said:
Return code -13 means that you are attempting to use SSL with a version of the library that does not support it. Most likely you're linking to something like libpaho-mqtt3a.so when you need to be linking to libpaho-mqtt3as.so.
The 's' in the library name indicates Secure/SSL.
Any way to solve this ?
@AdamMiltonBarker True. It seems you forgot to link to the right library. Here are the libraries

Aha, that would be a port bug. We should delete the "a" and "c" libraries, keeping only the "as" and "cs".
I've made the change in paho-mqtt version 1.2.0-2 and pushed to master (4353d848). Please try this version and let us know if it fixes the issue!
@atkawa7 I wasnt aware that we had to link to anything I thought VCPKG handled everything. @ras0219-msft great thanks will try now.
@ras0219-msft the update process is a bit rough lol. Had to uninstall a lot of programs and reinstall them. I did
git pull
vcpkg update
vcpkg remove --outdated
vcpkg install boost:x86-windows boost:x64-windows bzip2:x86-windows bzip2:x64-windows cpprestsdk:x64-windows cpprestsdk:x86-windows nlohmann-json:x86-windows openssl:x86-windows openssl:x64-windows paho-mqtt:x64-windows paho-mqtt:x86-windows zlib:x64-windows zlib:x86-windows
OUTPUT:
Installing package websocketpp:x64-windows... done
Building package cpprestsdk:x64-windows...
-- CURRENT_INSTALLED_DIR=D:/Installations/vcpkg/installed/x64-windows
-- DOWNLOADS=D:/Installations/vcpkg/downloads
-- CURRENT_PACKAGES_DIR=D:/Installations/vcpkg/packages/cpprestsdk_x64-windows
-- CURRENT_BUILDTREES_DIR=D:/Installations/vcpkg/buildtrees/cpprestsdk
-- CURRENT_PORT_DIR=D:/Installations/vcpkg/ports/cpprestsdk/.
-- Using cached D:/Installations/vcpkg/downloads/Microsoft-cpprestsdk-v2.9.0.tar.gz
-- Testing integrity of cached file...
CMake Error at D:/Installations/vcpkg/scripts/cmake/vcpkg_download_distfile.cmake:47 (message):
File does not have expected hash:
File path: [ D:/Installations/vcpkg/downloads/Microsoft-cpprestsdk-v2.9.0.tar.gz ]
Expected hash: [ 7f6af05e2aaf49fb5ba24f4fac43b7787345d46913831504925cefc60d1b62e38457e1d628d5de8b0db891b59716d2bfe63a494ca0b337d67fc9ca5447a5ba9b ]
Actual hash: [ c75de6ad33b3e8d2c6ba7c0955ed851d557f78652fb38a565de0cfbc99e7db89cb6fa405857512e5149df80356c51ae9335abd914c3c593fa6658ac50adf4e29 ]
Please delete the file and retry if this file should be downloaded again.
Call Stack (most recent call first):
D:/Installations/vcpkg/scripts/cmake/vcpkg_download_distfile.cmake:59 (test_hash)
D:/Installations/vcpkg/scripts/cmake/vcpkg_from_github.cmake:103 (vcpkg_download_distfile)
D:/Installations/vcpkg/ports/cpprestsdk/portfile.cmake:3 (vcpkg_from_github)
D:/Installations/vcpkg/scripts/ports.cmake:72 (include)
Error: Building package cpprestsdk:x64-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
Package: cpprestsdk:x64-windows
Vcpkg version: 0.0.86-2017-09-08-6d0f750646b0654ff5660ec70061a71a663d1bd9
Deleting D:/Installations/vcpkg/downloads/Microsoft-cpprestsdk-v2.9.0.tar.gz seems to working so far :)
OK this built. The issue with the .h files still remains but after amending MQTTAsync.h and MQTTClient.h with the following:
#if defined(_WIN32) || defined(_WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
I can now connect to my broker, still some issues on the TLS version but that is settings I need to amend, not related to the package I believe. So all looking good so far, will leave this open just in case. Thank you for the assistance so far guys.
Thought I would have this here rather than open new topic, cannot include json.hpp, the 64 version is installed and I can find the hpp file in:
D:\Installations\vcpkg\installedx64-windows\include\nlohmann
Could you try #include "nlohmann/json.hpp"? Because of the incredibly common name "json.hpp", we needed to move the file into a subfolder.
Can confirm everything working now, thanks guys.