OpenCL.framework cause my NIF library to crash

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

OpenCL.framework cause my NIF library to crash

This post has NOT been accepted by the mailing list yet.
Hi everyone,
I'm developing an Erlang binding to a C++ library of mine, which relies on OpenCL.
I set up a basic environment, with proper extern "C", as well as linker flags. In my case the magic words are:

-undefined dynamic_lookup -dynamiclib

Without these additional flags my NIF shared library won't compile. Everything work well until I try to link OpenCL within my NIF library. Bear in mind that I'm on Mac OS and OpenCL comes as a dynamic library (a Cocoa Framework to be more specific) and going to another platform like Linux or Windows is not feasible.
When I try to load my "new" NIF library (with OpenCL linked with it), this is the result:

laetus alfredodinapoli$ rebar eunit
==> elaetus (eunit)
Compiled src/elaetus_app.erl
Compiled src/elaetus_sup.erl
Compiled src/elaetus.erl
Trace/BPT trap: 5

Which is not very informative about what's going wrong. But I suspect it may be related to the dynamic nature of the OpenCL library. In fact, linking my framework, which is a static library, doesn't cause any issue.
I would like to know:

a) If anyone has had any contact with the NIF + MacOs + C++ world
b) If anyone know a workaround for this annoying situation.

Thanks in advance,
Alfredo Di Napoli