在Linux中显式导出共享库函数 [英] Explicitly exporting shared library functions in Linux

查看:374
本文介绍了在Linux中显式导出共享库函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个等价的 __ declspec(dllexport)表示法从共享库中显式导出函数?由于某些原因,我使用的工具链,不是类成员的函数不会出现在生成的共享库文件中。

Is there a Linux equivalent of __declspec(dllexport) notation for explicitly exporting a function from a shared library? For some reason with the toolchain I'm using, functions that aren't class members don't appear in the resulting shared library file.

推荐答案

__attribute__((visibility("default")))

根据我的知识,没有等效的 __ declspec(dllimport)

And there is no equivalent of __declspec(dllimport) to my knowledge.

#if defined(_MSC_VER)
    //  Microsoft 
    #define EXPORT __declspec(dllexport)
    #define IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
    //  GCC
    #define EXPORT __attribute__((visibility("default")))
    #define IMPORT
#else
    //  do nothing and hope for the best?
    #define EXPORT
    #define IMPORT
    #pragma warning Unknown dynamic link import/export semantics.
#endif

这篇关于在Linux中显式导出共享库函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆