title: Paho C++ Lib integration: Unresolved external errors
body: <p>I am trying to use the Paho C++ library within my own C++ project (Visual Studio 2017).
  I have built and installed the Paho C lib and Paho C++ lib as it was explained <a href="https://stackoverflow.com/questions/56455358/how-to-build-paho-mqtt-c-on-windows">here</a> .
  So far so good. Afterwards, I created a new (blank) C++ project in Visual Studio 2017 and applied the following changes in the project properties:</p>
  
  <ol>
  <li>In Tab C/C++ / General:
  In "Additional Include Directories", I added two include paths (from both paho c and paho c++ installation path):</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/42dp3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/42dp3.png" alt="Additional Include Directories"></a></p>
  
  <ol start="2">
  <li>In Tab Linker / General:
  In "Additional Library Directories", I added the paths to the lib folders (from both paho c and paho c++ installation path):</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/Bx4Ua.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bx4Ua.png" alt="Additional Library Directories"></a></p>
  
  <ol start="3">
  <li>In Tab Linker/Input:
  In "Additional Dependencies", I added the library names of both the paho c and paho c++ library.</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/wK2Va.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wK2Va.png" alt="enter image description here"></a></p>
  
  <ol start="4">
  <li>Furthermore, I have copied the paho-mqtt3c.dll into the Debug folder of my C++-project  and I have included the topic_publish.cpp sample file (to be my main). </li>
  </ol>
  
  <p>ISSUE: If I try to build the application, I am getting 20 linking errors.</p>
  
  <pre><code>1&gt;------ Build started: Project: PahoCppLibTest, Configuration: Debug Win32 ------
  1&gt;Main.cpp
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_setDisconnected referenced in function "public: void __thiscall mqtt::async_client::set_disconnected_handler(class std::function&lt;void __cdecl(class mqtt::properties const &amp;,enum mqtt::ReasonCode)&gt;)" (?set_disconnected_handler@async_client@mqtt@@QAEXV?$function@$$A6AXABVproperties@mqtt@@W4ReasonCode@2@@Z@std@@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_setCallbacks referenced in function "public: virtual void __thiscall mqtt::async_client::set_callback(class mqtt::callback &amp;)" (?set_callback@async_client@mqtt@@UAEXAAVcallback@2@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_setConnectionLostCallback referenced in function "public: void __thiscall mqtt::async_client::set_connection_lost_handler(class std::function&lt;void __cdecl(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)&gt;)" (?set_connection_lost_handler@async_client@mqtt@@QAEXV?$function@$$A6AXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z@std@@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_setMessageArrivedCallback referenced in function "public: void __thiscall mqtt::async_client::set_message_callback(class std::function&lt;void __cdecl(class std::shared_ptr&lt;class mqtt::message const &gt;)&gt;)" (?set_message_callback@async_client@mqtt@@QAEXV?$function@$$A6AXV?$shared_ptr@$$CBVmessage@mqtt@@@std@@@Z@std@@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_setConnected referenced in function "public: virtual void __thiscall mqtt::async_client::set_callback(class mqtt::callback &amp;)" (?set_callback@async_client@mqtt@@UAEXAAVcallback@2@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_reconnect referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::reconnect(void)" (?reconnect@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@XZ)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_createWithOptions referenced in function "public: __thiscall mqtt::async_client::async_client(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,int,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (??0async_client@mqtt@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0H0@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_connect referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::connect(class mqtt::connect_options)" (?connect@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@Vconnect_options@2@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_disconnect referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::disconnect(class mqtt::disconnect_options)" (?disconnect@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@Vdisconnect_options@2@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_isConnected referenced in function "public: virtual bool __thiscall mqtt::async_client::is_connected(void)const " (?is_connected@async_client@mqtt@@UBE_NXZ)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_subscribe referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::subscribe(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,int,class mqtt::subscribe_options const &amp;)" (?subscribe@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@HABVsubscribe_options@2@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_subscribeMany referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::subscribe(class std::shared_ptr&lt;class mqtt::string_collection const &gt;,class std::vector&lt;int,class std::allocator&lt;int&gt; &gt; const &amp;,class std::vector&lt;class mqtt::subscribe_options,class std::allocator&lt;class mqtt::subscribe_options&gt; &gt; const &amp;)" (?subscribe@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@V?$shared_ptr@$$CBVstring_collection@mqtt@@@4@ABV?$vector@HV?$allocator@H@std@@@4@ABV?$vector@Vsubscribe_options@mqtt@@V?$allocator@Vsubscribe_options@mqtt@@@std@@@4@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_unsubscribe referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::unsubscribe(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)" (?unsubscribe@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_unsubscribeMany referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::token&gt; __thiscall mqtt::async_client::unsubscribe(class std::shared_ptr&lt;class mqtt::string_collection const &gt;)" (?unsubscribe@async_client@mqtt@@UAE?AV?$shared_ptr@Vtoken@mqtt@@@std@@V?$shared_ptr@$$CBVstring_collection@mqtt@@@4@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_sendMessage referenced in function "public: virtual class std::shared_ptr&lt;class mqtt::delivery_token&gt; __thiscall mqtt::async_client::publish(class std::shared_ptr&lt;class mqtt::message const &gt;)" (?publish@async_client@mqtt@@UAE?AV?$shared_ptr@Vdelivery_token@mqtt@@@std@@V?$shared_ptr@$$CBVmessage@mqtt@@@4@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_freeMessage referenced in function "private: static int __cdecl mqtt::async_client::on_message_arrived(void *,char *,int,struct MQTTAsync_message *)" (?on_message_arrived@async_client@mqtt@@CAHPAXPADHPAUMQTTAsync_message@@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_free referenced in function "private: static int __cdecl mqtt::async_client::on_message_arrived(void *,char *,int,struct MQTTAsync_message *)" (?on_message_arrived@async_client@mqtt@@CAHPAXPADHPAUMQTTAsync_message@@@Z)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_destroy referenced in function "public: virtual __thiscall mqtt::async_client::~async_client(void)" (??1async_client@mqtt@@UAE@XZ)
  1&gt;paho-mqttpp3-static.lib(async_client.obj) : error LNK2019: unresolved external symbol _MQTTAsync_strerror referenced in function "public: static class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __cdecl mqtt::exception::error_str(int)" (?error_str@exception@mqtt@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
  1&gt;C:\mqtt\projects\PahoCppLibTest\Debug\PahoCppLibTest.exe : fatal error LNK1120: 19 unresolved externals
  1&gt;Done building project "PahoCppLibTest.vcxproj" -- FAILED.
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p><strong>EDIT:</strong>
  The lib is used by including it like follows:</p>
  
  <pre><code>#include "mqtt/async_client.h"
  </code></pre>
  
  <p>This is the main code I am using (it's the "topic_publish.cpp" sample from the paho c++ library):</p>
  
  <pre><code>// topic_publish.cpp
  //
  // This is a Paho MQTT C++ client, sample application.
  //
  // It's an example of how to send messages as an MQTT publisher using the
  // C++ asynchronous client interface using a 'topic' object to repeatedly
  // send data to the same topic.
  //
  // The sample demonstrates:
  //  - Connecting to an MQTT server/broker
  //  - Publishing messages
  //  - Use of the 'topic' class
  //
  
  /*******************************************************************************
   * Copyright (c) 2019 Frank Pagliughi &lt;fpagliughi@mindspring.com&gt;
   *
   * 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:
   *    Frank Pagliughi - initial implementation and documentation
   *******************************************************************************/
  
  #include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;string&gt;
  #include &lt;thread&gt;   // For sleep
  #include &lt;atomic&gt;
  #include &lt;chrono&gt;
  #include &lt;cstring&gt;
  #include "mqtt/async_client.h"
  
  using namespace std;
  
  const string DFLT_SERVER_ADDRESS{ "tcp://localhost:1883" };
  
  const string TOPIC{ "test" };
  const int QOS = 1;
  
  const char* PAYLOADS[] = {
      "Hello World!",
      "Hi there!",
      "Is anyone listening?",
      "Someone is always listening.",
      nullptr
  };
  
  const auto TIMEOUT = std::chrono::seconds(10);
  
  /////////////////////////////////////////////////////////////////////////////
  
  int main(int argc, char* argv[])
  {
      string address = (argc &gt; 1) ? string(argv[1]) : DFLT_SERVER_ADDRESS;
  
      cout &lt;&lt; "Initializing for server '" &lt;&lt; address &lt;&lt; "'..." &lt;&lt; endl;
      mqtt::async_client cli(address, "");
  
      cout &lt;&lt; "  ...OK" &lt;&lt; endl;
  
      try {
          cout &lt;&lt; "\nConnecting..." &lt;&lt; endl;
          cli.connect()-&gt;wait();
          cout &lt;&lt; "  ...OK" &lt;&lt; endl;
  
          cout &lt;&lt; "\nPublishing messages..." &lt;&lt; endl;
  
          mqtt::topic top(cli, "test", QOS);
          mqtt::token_ptr tok;
  
          size_t i = 0;
          while (PAYLOADS[i]) {
              tok = top.publish(PAYLOADS[i++]);
          }
          tok-&gt;wait();    // Just wait for the last one to complete.
          cout &lt;&lt; "OK" &lt;&lt; endl;
  
          // Disconnect
          cout &lt;&lt; "\nDisconnecting..." &lt;&lt; endl;
          cli.disconnect()-&gt;wait();
          cout &lt;&lt; "  ...OK" &lt;&lt; endl;
      }
      catch (const mqtt::exception&amp; exc) {
          cerr &lt;&lt; exc.what() &lt;&lt; endl;
          return 1;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>I suggest the problem lies within the paho-mqttpp3-static.lib file, but I do not know how to solve this. Any suggestions?</p>