[erlang-questions] Error from on_load function of NIF module

Sverker Eriksson <>
Thu Jan 7 18:29:33 CET 2016

On 01/07/2016 04:50 PM, Abhishek Singh wrote:
> I was able to overcome this error by copying macro statements from 
> below link:
> https://github.com/couchbase/couchdb/blob/master/src/couchdb/priv/couch_ejson_compare/couch_ejson_compare.c#L486-L493
#ifndef _MSC_VER
#if defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#elif defined __GNUC__
__attribute__ ((visibility("default")))


> Not sure what exactly it does, would be useful if somebody could throw 
> some light on it.

My guess is the .so file is linked with option -fvisibility=hidden
which according to the gcc man page "...can very substantially improve
linking and load times of shared object libraries, produce more 
optimized code,
provide near-perfect API export and prevent symbol clashes".

That is, all symbols are made hidden by default and the above macro cludge
makes an exception for the "nif_init" function that needs to be visible.

I will see if I can incorporate that into the ERL_NIF_INIT macro.

/Sverker, Erlang/OTP

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160107/89d7b62d/attachment.html>

More information about the erlang-questions mailing list