glfw dynamic loading cause core dump

Hello FreeBSD folks,

I have a problem loading dynamically the glfw (/usr/ports/graphics/glfw) library. I need dynamic loading because I want to bind this library with a foreign language (through FFI).

Suppose the minimal library libcglfw.c:
Code:
#include <GL/glfw.h>
 
int my_glfw_init() {
   return glfwInit();
}
compiled by @ gcc -fPIC -shared -o libcglfw.so libcglfw.c -L/usr/local/lib -lglfw and the simple test program test_cglfw.c:
Code:
 #include <stdlib.h>
 #include <stdio.h>
 #include <dlfcn.h>
 
 typedef int (*my_init_function)(void);
 
 int main (int argc, char const* argv[]) { 
   const char *error;
   void *module;
   my_init_function my_init;
   
   /* Load dynamically loaded library */
   module = dlopen("libcglfw.so", RTLD_LAZY);
   if (!module) {
     fprintf(stderr, "Couldn't open libcglfw.so: %s\n", dlerror());
     exit(1);
   }
    
   /* Get symbol */
   dlerror();
   my_init = dlsym(module, "my_init");
   if ((error = dlerror())) {
     fprintf(stderr, "Couldn't find hello: %s\n", error);
     exit(1);
   }
   
   return my_init();
 }
compiled by @ gcc -o test_cglfw test_cglfw.c. And now I have a core dump:
Code:
[CMD=@]./test_cglfw[/CMD]
Unable to find pthread_mutexattr_setkind_np versioned symbol. Aborting.
Abort(coredump)

It seems that the pthread library cannot be dynamically loaded somehow but I couldn't find on the Internet any similar problem.

Here is some information about my setup.
  • The fbsd FreeBSD box:
    Code:
    [CMD=@]uname -a[/CMD]
    FreeBSD darkstar 9.1-STABLE FreeBSD 9.1-STABLE #2: Thu Jan 31 20:41:22 CET 2013     root@darkstar:/usr/obj/usr/src/sys/THINKPKERNEL  amd64
  • My environment variables: @ export
  • The ldd tree of the shared object: @ ldd libcglfw.so
  • gdb introspection on core file: @ gdb test_cglfw test_cglfw.core
  • Trace system calls of the crash (see the test_cglfw.trace.gz in attachment):
    Code:
    [CMD=@]truss -o test_cglfw.trace ./test_cglfw[/CMD]
    Unable to find pthread_mutexattr_setkind_np versioned symbol. Aborting.
Any trick to overcome this problem?

Thank you all ;)
 

Attachments

  • test_cglfw.trace.gz
    3 KB · Views: 161
Back
Top