Nambers / MiraiCP

c++ SDK of Mirai
https://eritque-arcus.tech/MiraiCP/
GNU Affero General Public License v3.0
177 stars 31 forks source link

插件加载失败,找不到符号 #145

Closed Adanelia closed 1 year ago

Adanelia commented 1 year ago

Code of Conduct

问题描述

描述

我在debian上使用gcc编译的插件加载时出错,mirai提示“找不到符号 插件入口”。 (libLoader也是gcc编译的。) 和 #119 的问题

failed to find symbol in plugin 应该是一样的。 看起来是只修复了MSVC没有适配gcc。

解决办法

我尝试了3种解决办法。

第一种

在插件的CMakeLists.txt里删除33行的-fvisibility=hidden。 直接不隐藏符号。

第二种

在插件的single_include/MiraiCP/MiraiCP.hpp的四个函数添加可见属性。

extern "C" {
MIRAICP_EXPORT void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);
MIRAICP_EXPORT void FUNC_EVENT(std::string content);
MIRAICP_EXPORT void FUNC_EXIT();
MIRAICP_EXPORT const MiraiCP::PluginConfig &PLUGIN_INFO();
}

改成

extern "C" {
MIRAICP_EXPORT __attribute__ ((visibility ("default"))) void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);
MIRAICP_EXPORT __attribute__ ((visibility ("default"))) void FUNC_EVENT(std::string content);
MIRAICP_EXPORT __attribute__ ((visibility ("default"))) void FUNC_EXIT();
MIRAICP_EXPORT __attribute__ ((visibility ("default"))) const MiraiCP::PluginConfig &PLUGIN_INFO();
}

第三种

在single_include/MiraiCP/MiraiCP.hpp第150行(定义MIRAICP_EXPORT)下面添加如下:

#elif MIRAICP_GCC
#undef MIRAICP_EXPORT
#define MIRAICP_EXPORT __attribute__ ((visibility ("default")))

我觉得这个方法应该是最正确的,但是编译的时候会产生两个警告。

日志

No response

版本

2.13.0-alpha-2

组件

Plugin(SDK)

编译器

gcc/g++

系统

Linux/Unix

架构

arm64/aarch64

Antares0982 commented 1 year ago

无法复现,Debian4.19 gcc 8.3.0,请提供更多信息

Adanelia @.***> 于 2022年11月19日周六 14:52写道:

Code of Conduct

  • I conform

问题描述 描述

我在debian上使用gcc编译的插件加载时出错,mirai提示“找不到符号 插件入口”。 (libLoader也是gcc编译的。) 和 #119 https://github.com/Nambers/MiraiCP/issues/119 的问题

failed to find symbol in plugin 应该是一样的。 看起来是只修复了MSVC没有适配gcc。

解决办法

我尝试了3种解决办法。 第一种

在插件的CMakeLists.txt里删除33行的-fvisibility=hidden。 直接不隐藏符号。 第二种

在插件的single_include/MiraiCP/MiraiCP.hpp的四个函数添加可见属性。

extern "C" {

MIRAICP_EXPORT void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);

MIRAICP_EXPORT void FUNC_EVENT(std::string content);

MIRAICP_EXPORT void FUNC_EXIT();

MIRAICP_EXPORT const MiraiCP::PluginConfig &PLUGIN_INFO();

}

改成

extern "C" {

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_EVENT(std::string content);

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_EXIT();

MIRAICP_EXPORT attribute ((visibility ("default"))) const MiraiCP::PluginConfig &PLUGIN_INFO();

}

第三种

在single_include/MiraiCP/MiraiCP.hpp第150行(定义MIRAICP_EXPORT)下面添加如下:

elif MIRAICP_GCC

undef MIRAICP_EXPORT

define MIRAICP_EXPORT attribute ((visibility ("default")))

我觉得这个方法应该是最正确的,但是编译的时候会产生两个警告。 日志

No response 版本

2.13.0-alpha-2 组件

Plugin(SDK) 编译器

gcc/g++ 系统

Linux/Unix 架构

arm64/aarch64

— Reply to this email directly, view it on GitHub https://github.com/Nambers/MiraiCP/issues/145, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYUJZRIMDITJZKEU47KZ53WJB2LPANCNFSM6AAAAAASFFEV2U . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Antares0982 commented 1 year ago

这个问题是仅在arm架构上能复现?如果是的话建议你用第三种方法,这个问题我们之后会改掉。arm架构我们没有做过测试

林世羽 @.***> 于 2022年11月19日周六 15:48写道:

无法复现,Debian4.19 gcc 8.3.0,请提供更多信息

Adanelia @.***> 于 2022年11月19日周六 14:52写道:

Code of Conduct

  • I conform

问题描述 描述

我在debian上使用gcc编译的插件加载时出错,mirai提示“找不到符号 插件入口”。 (libLoader也是gcc编译的。) 和 #119 https://github.com/Nambers/MiraiCP/issues/119 的问题

failed to find symbol in plugin 应该是一样的。 看起来是只修复了MSVC没有适配gcc。

解决办法

我尝试了3种解决办法。 第一种

在插件的CMakeLists.txt里删除33行的-fvisibility=hidden。 直接不隐藏符号。 第二种

在插件的single_include/MiraiCP/MiraiCP.hpp的四个函数添加可见属性。

extern "C" {

MIRAICP_EXPORT void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);

MIRAICP_EXPORT void FUNC_EVENT(std::string content);

MIRAICP_EXPORT void FUNC_EXIT();

MIRAICP_EXPORT const MiraiCP::PluginConfig &PLUGIN_INFO();

}

改成

extern "C" {

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_ENTRANCE(const LibLoader::LoaderApi::interface_funcs &);

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_EVENT(std::string content);

MIRAICP_EXPORT attribute ((visibility ("default"))) void FUNC_EXIT();

MIRAICP_EXPORT attribute ((visibility ("default"))) const MiraiCP::PluginConfig &PLUGIN_INFO();

}

第三种

在single_include/MiraiCP/MiraiCP.hpp第150行(定义MIRAICP_EXPORT)下面添加如下:

elif MIRAICP_GCC

undef MIRAICP_EXPORT

define MIRAICP_EXPORT attribute ((visibility ("default")))

我觉得这个方法应该是最正确的,但是编译的时候会产生两个警告。 日志

No response 版本

2.13.0-alpha-2 组件

Plugin(SDK) 编译器

gcc/g++ 系统

Linux/Unix 架构

arm64/aarch64

— Reply to this email directly, view it on GitHub https://github.com/Nambers/MiraiCP/issues/145, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYUJZRIMDITJZKEU47KZ53WJB2LPANCNFSM6AAAAAASFFEV2U . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Adanelia commented 1 year ago

系统: debian bullseye gcc --version: gcc (Debian 10.2.1-6) 10.2.1 20210110 cmake --version: cmake version 3.18.4 MiraiCP版本: 9e8833b MiraiCP-template版本: ecda3d7

我这里只有arm的,没法测试x86_64会不会出现这个问题……

Antares0982 commented 1 year ago

x86不会复现,之后会加入arm支持

Adanelia @.***> 于 2022年11月19日周六 16:22写道:

系统: debian bullseye gcc --version: gcc (Debian 10.2.1-6) 10.2.1 20210110 cmake --version: cmake version 3.18.4 MiraiCP版本: 9e8833b https://github.com/Nambers/MiraiCP/commit/9e8833baa7fd15d193d6a5a589167cac5a568d42 MiraiCP: ecda3d7

我这里只有arm的,没法测试x86_64会不会出现这个问题……

— Reply to this email directly, view it on GitHub https://github.com/Nambers/MiraiCP/issues/145#issuecomment-1320832819, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYUJZWDQUX4VL45FQULB63WJCE3JANCNFSM6AAAAAASFFEV2U . You are receiving this because you commented.Message ID: @.***>

Adanelia commented 1 year ago

x86不会复现,之后会加入arm支持 Adanelia @.> 于 2022年11月19日周六 16:22写道: 系统: debian bullseye gcc --version: gcc (Debian 10.2.1-6) 10.2.1 20210110 cmake --version: cmake version 3.18.4 MiraiCP版本: 9e8833b <9e8833b> MiraiCP: ecda3d7 我这里只有arm的,没法测试x86_64会不会出现这个问题…… — Reply to this email directly, view it on GitHub <#145 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYUJZWDQUX4VL45FQULB63WJCE3JANCNFSM6AAAAAASFFEV2U . You are receiving this because you commented.Message ID: @.>

好,那我就关issue了

Antares0982 commented 1 year ago

辛苦了!谢谢提供arm架构编译运行相关的信息,以后如果有什么问题也麻烦你直接开issue!

Adanelia @.***> 于 2022年11月19日周六 16:33写道:

Closed #145 https://github.com/Nambers/MiraiCP/issues/145 as completed.

— Reply to this email directly, view it on GitHub https://github.com/Nambers/MiraiCP/issues/145#event-7849227855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYUJZTQZCIICCXZ4QYIZ33WJCGG3ANCNFSM6AAAAAASFFEV2U . You are receiving this because you commented.Message ID: @.***>

Adanelia commented 1 year ago

好的,不客气