title: openGL 3 issue : undefined reference to _glapi_tls_Dispatch
body: <p>I'm trying to compile a simple test program from <a href="http://open.gl/introduction">http://open.gl/introduction</a> :</p>
  
  <pre><code>#include &lt;GLFW/glfw3.h&gt;
  #include &lt;thread&gt;
  
  int main()
  {
      glfwInit();
      std::this_thread::sleep_for(std::chrono::seconds(1));
      glfwTerminate();
  }
  </code></pre>
  
  <p>I use the following to compile:</p>
  
  <pre><code>&gt;&gt; g++ -c tutorial01.cpp -o tutorial01.o -std=c++11
  &gt;&gt; g++  tutorial01.o -o tutorial01 -lglfw3 -lGL -lXrandr -lX11 -lXi -lGLEW
  /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libGL.so: undefined reference to `_glapi_tls_Dispatch'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Here are some extra info about the problem:</p>
  
  <pre><code>&gt;&gt; readlink -f "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libGL.so"
  /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0
  
  &gt;&gt; nm -D /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0 | grep _glapi_tls_Dispatch
  U _glapi_tls_Dispatch
  
  &gt;&gt; ldd /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0
  linux-vdso.so.1 (0x00007fff0b200000)
  libglapi.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007ff437f80000)
  libXext.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007ff437d68000)
  libXdamage.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007ff437b60000)
  libXfixes.so.3 =&gt; /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007ff437958000)
  libX11-xcb.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007ff437750000)
  libX11.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007ff437410000)
  libxcb-glx.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007ff4371f8000)
  libxcb-dri2.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007ff436ff0000)
  libxcb.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007ff436dd0000)
  libXxf86vm.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007ff436bc8000)
  libdrm.so.2 =&gt; /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007ff4369b8000)
  libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff4366b0000)
  libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff436490000)
  libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff436288000)
  libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff435ed8000)
  libXau.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007ff435cd0000)
  libXdmcp.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007ff435ac8000)
  /lib64/ld-linux-x86-64.so.2 (0x00007ff438428000)
  
  &gt;&gt; nm -D /usr/lib/x86_64-linux-gnu/libglapi.so.0 |grep _glapi_tls_Dispatch
  0000000000000000 D _glapi_tls_Dispatch
  </code></pre>
  
  <p>The symbol <code>_glapi_tls_Dispatch</code> is defined in libglapi.so, ligGL.so depends to libglapi.so, so why does the link fail?</p>
  
  <p>Does anyone have a clue ?</p>