Dynamic Shared Library compilation with g++

前端 未结 4 1467
别跟我提以往
别跟我提以往 2021-01-30 18:44

I\'m trying to compile the following simple DL library example code from Program-Library-HOWTO with g++. This is just an example so I can learn how to use and write shared libr

4条回答
  •  萌比男神i
    2021-01-30 19:29

    In C++, you have to perform a reinterpret_cast (not a C cast):

    typedef double (* double_from_double_function_t(double));
    …
    double_from_double_function_t cosine = reinterpret_cast(dlsym(handle, "cos"));
    

提交回复
热议问题