Load multiple copies of a shared library

后端 未结 4 1759
栀梦
栀梦 2020-12-10 04:49

I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has globa

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 05:12

    You can load multiple independent copies of the library like this:

    #define _GNU_SOURCE
    #include 
    ...
    void *handle = dlmopen(LM_ID_NEWLM, "/path/to/library.so", RTLD_NOW);
    

    More info here.

提交回复
热议问题