I have installed paho-mqttpp3:x64-windows using vcpkg and running the below code in Visual Studio with build option in x64.
#include <iostream>
#include "mqtt/async_client.h"
int main()
{
std::cout << "Hello World!\n";
}
When I am running above code it generate following error
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> error C2059: syntax error: 'const'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(85):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(85):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(85):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(85):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(109):
> error C3646: 'data': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(109):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(110):
> error C3646: 'value': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(110):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(123):
> error C2143: syntax error: missing ';' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(123):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(123):
> error C2238: unexpected token(s) preceding ';'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(141):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(141):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(141):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(141):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(141):
> error C2143: syntax error: missing ',' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(164):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(164):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(164):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(164):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(171):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(171):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(171):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(171):
> error C2146: syntax error: missing ';' before identifier
> 'MQTTProperties'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(179):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(179):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(179):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(179):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(188):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(188):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(188):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(188):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(196):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(196):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(196):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(196):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(206):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(206):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(206):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(206):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(214):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(214):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(214):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(214):
> error C2146: syntax error: missing ';' before identifier
> 'MQTTProperty'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(223):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(223):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(223):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(223):
> error C2146: syntax error: missing ';' before identifier
> 'MQTTProperty'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttreasoncodes.h(83):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttreasoncodes.h(83):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttreasoncodes.h(83):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttreasoncodes.h(83):
> error C2059: syntax error: 'const'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(223):
> error C3646: 'popen': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(223):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(227):
> error C3646: 'pclose': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(227):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(231):
> error C3646: 'pput': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(231):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(235):
> error C3646: 'pget': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(235):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(239):
> error C3646: 'premove': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(239):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(243):
> error C3646: 'pkeys': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(243):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(247):
> error C3646: 'pclear': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(247):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(251):
> error C3646: 'pcontainskey': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttclientpersistence.h(251):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C2065: 'MQTTAsync_init_options': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C2065: 'inits': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(233):
> error C2182: 'MQTTAsync_global_init': illegal use of type 'void'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(346):
> error C2061: syntax error: identifier 'MQTTAsync_message'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(366):
> error C2061: syntax error: identifier 'MQTTAsync_token'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C2065: 'MQTTAsync': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(424):
> error C2146: syntax error: missing ')' before identifier 'handle'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(431):
> error C3646: 'token': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(431):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(447):
> error C3646: 'token': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(447):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(466):
> error C3646: 'token': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(466):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(477):
> error C3646: 'message': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(477):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(497):
> error C3646: 'token': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(497):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(512):
> error C3646: 'message': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(512):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(543):
> error C2061: syntax error: identifier 'MQTTAsync_successData'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(556):
> error C2061: syntax error: identifier 'MQTTAsync_successData5'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(568):
> error C2061: syntax error: identifier 'MQTTAsync_failureData'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(580):
> error C2061: syntax error: identifier 'MQTTAsync_failureData5'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(594):
> error C2143: syntax error: missing ';' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(594):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(594):
> error C2238: unexpected token(s) preceding ';'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(600):
> error C2143: syntax error: missing ';' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(600):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(600):
> error C2238: unexpected token(s) preceding ';'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(612):
> error C3646: 'token': unknown override specifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(612):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(618):
> error C2143: syntax error: missing ';' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(618):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(618):
> error C2238: unexpected token(s) preceding ';'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(624):
> error C2143: syntax error: missing ';' before '*'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(624):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(624):
> error C2238: unexpected token(s) preceding ';'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C2065: 'MQTTAsync': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(677):
> error C2146: syntax error: missing ')' before identifier 'handle'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C2065: 'MQTTAsync': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(700):
> error C2146: syntax error: missing ')' before identifier 'handle'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C2065: 'MQTTAsync': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(724):
> error C2146: syntax error: missing ')' before identifier 'handle'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C2374: '__attribute__': redefinition; multiple initialization
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttproperties.h(67):
> note: see declaration of '__attribute__'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C2448: '__attribute__': function-style initializer appears to be
> a function definition
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C2065: 'MQTTAsync': undeclared identifier
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(746):
> error C2146: syntax error: missing ')' before identifier 'handle'
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(761):
> error C3861: 'visibility': identifier not found
> 1>d:\vcpkg\packages\paho-mqtt_x64-windows\include\paho-mqtt\mqttasync.h(761):
> fatal error C1003: error count exceeds 100; stopping compilation
But when I installed paho-mqttpp3:x86-windows using vcpkg and running the same code in Visual Studio with build option in x86. It get successfully run.
#include <iostream>
#include "mqtt/async_client.h"
int main()
{
std::cout << "Hello World!\n";
}
OS - Windows 10 64 bit Home
Visual Studio - 15.9.19
paho-mqtt installed using vcpkg.
I found the solution for this issue is that you have to change few things in MQTT files.
Changes to be done in the content of the following file which is inside paho-mqtt folder. In my case it is inside D:\vcpkg\installed\x64-windows\include\paho-mqtt
MQTTAsync
MQTTClient
MQTTProperties
MQTTReasonCodes
In all the above file change the following content.
#if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#else
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#endif
Macro WIN32 and WIN64 should be changed to _WIN32 and _WIN64
You will find it like this:
#if defined(WIN32) || defined(WIN64)
Change to
#if defined(_WIN32) || defined(_WIN64)
OR
Note: Don't follow below steps if you had already followed above procedure.
You can add WIN64 in your Preprocessor Directory of your projects property of Visual Studio.
Go-to Solution Explorer --> Properties --> C/C++ --> Preprocessor.
Add WIN64 inside Preprocessor Directory