openGL 3 issue : undefined reference to _glapi_tls_Dispatch

I'm trying to compile a simple test program from http://open.gl/introduction :

#include <GLFW/glfw3.h>
#include <thread>

int main()
{
    glfwInit();
    std::this_thread::sleep_for(std::chrono::seconds(1));
    glfwTerminate();
}

I use the following to compile:

>> g++ -c tutorial01.cpp -o tutorial01.o -std=c++11
>> 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

Here are some extra info about the problem:

>> 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

>> nm -D /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0 | grep _glapi_tls_Dispatch
U _glapi_tls_Dispatch

>> ldd /usr/lib/x86_64-linux-gnu/libGL.so.1.2.0
linux-vdso.so.1 (0x00007fff0b200000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007ff437f80000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007ff437d68000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007ff437b60000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007ff437958000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007ff437750000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007ff437410000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007ff4371f8000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007ff436ff0000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007ff436dd0000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007ff436bc8000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007ff4369b8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff4366b0000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff436490000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff436288000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff435ed8000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007ff435cd0000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007ff435ac8000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff438428000)

>> nm -D /usr/lib/x86_64-linux-gnu/libglapi.so.0 |grep _glapi_tls_Dispatch
0000000000000000 D _glapi_tls_Dispatch

The symbol _glapi_tls_Dispatch is defined in libglapi.so, ligGL.so depends to libglapi.so, so why does the link fail?

Does anyone have a clue ?

Answers


Did a quick search of libglfw3-dev package and it lists the library file as -lglfw not -lglfw3 on my system. Dunno if that helps or not.

apt-file search libglfw | grep -v doc
libglfw-dev: /usr/lib/x86_64-linux-gnu/libglfw.a
libglfw-dev: /usr/lib/x86_64-linux-gnu/libglfw.so
libglfw-dev: /usr/lib/x86_64-linux-gnu/pkgconfig/libglfw.pc
libglfw2: /usr/lib/x86_64-linux-gnu/libglfw.so.2
libglfw3: /usr/lib/x86_64-linux-gnu/libglfw.so.3
libglfw3: /usr/lib/x86_64-linux-gnu/libglfw.so.3.1
libglfw3-dev: /usr/lib/x86_64-linux-gnu/libglfw.so

Need Your Help

Detecting Regions Described by Lines on HTML5 Canvas

javascript html5 canvas geometry jcanvas

Start with a 2d grid on an HTML5 canvas. The user creates lines by plotting points - up to 5 lines.

Google map Splitter layout

jquery-ui google-maps layout

Is there is any layout like this