title: Finding symbol with dlsym for symbol in namespace
body: <p>I have a dynamic library I want to load. I have defined a function <code>add()</code>:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "mymath.h"
  
  #define EXPORT __attribute__((visibility("default")))
  
  
  EXPORT
  int mymath::add(int a, int b) {
      return a + b;
  }
  </code></pre>
  
  <p>This symbol sits within a namespace called <code>mymath</code>:</p>
  
  <pre><code>namespace mymath {
      int add(int, int);
  }
  </code></pre>
  
  <p>I have compiled this library with following command:</p>
  
  <pre><code>llvm-g++ -Iinclude -dynamiclib -std=c++17 src/mymath.cpp -current_version 1.0 -compatibility_version 1.0 -fvisibility=hidden -o bin/mymath.dylib
  </code></pre>
  
  <p>Now I want to use it within another program loading this symbol in runtime. I have come to following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;dlfcn.h&gt;
  #include "mymath.h"
  
  int main() {
      const char* libName = "bin/mymath.dylib";
      void *libHandle;
      std::cout &lt;&lt; "# main() starts" &lt;&lt; std::endl;
      libHandle = dlopen(libName, RTLD_NOW);
      if(libHandle == NULL) {
          std::cerr &lt;&lt; "Error opening mymath:\n" &lt;&lt; dlerror() &lt;&lt; std::endl;;
          return 1;
      }
      void (*mymath_add) = dlsym(libHandle, "mymath:add");
      if(mymath_add == NULL) {
          std::cerr &lt;&lt; "Error opening while getting address of mymath::add:\n" &lt;&lt; dlerror() &lt;&lt; std::endl;;
          return 2;
      }
      std::cout &lt;&lt; "# main() exits" &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>And get this error when running it</p>
  
  <pre><code> $ make
  clang++ -Wall -Wextra -std=c++17 -g -Iinclude -Llib src/main.cpp -o bin/main
   wgonczaronek  Wiktor-Gonczaronek  ~/Projects/…/macos-pt2  master  ? 
   $ ./bin/main
  # main() starts
  Error opening while getting address of mymath::add:
  dlsym(0x7ffac9402a90, mymath:add): symbol not found
  </code></pre>
  
  <p>I have tried with symbols I found using <code>nm</code> command, but get same error. How can I load this symbol using namespace?</p>