c++ - Visual Studio 2017 ARM 交叉编译链接器崩溃
问题描述
所以我一直在为我的树莓派做一个项目。但为了方便起见,我想使用 Visual Studio 2017 构建它。它是基于插件的,因此插件实现一个接口并导出一个函数,该函数将一个实例返回到实现类。我遇到的问题是编译器崩溃,只有当我尝试导出所述函数时才会发生这种情况。
extern "C" Plugin __declspec(dllexport) *CreatePlugin(Data *r);
这是插件必须实现的函数的声明,以返回其“插件”接口的实现。
MSVC 编译器给我以下错误消息:
1> Bibliothek "build\Debug\Raspberry\libSMH.so" und Objekt "build\Debug\Raspberry\libSMH.exp" werden erstellt.
1>
1>LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
1>
1> Version 14.15.26726.0
1>
1> ExceptionCode = C0000005
1> ExceptionFlags = 00000000
1> ExceptionAddress = 0F20CC4E (0F200000) "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\bin\HostX86\arm\VCRUNTIME140.dll"
1> NumberParameters = 00000002
1> ExceptionInformation[ 0] = 00000001
1> ExceptionInformation[ 1] = FEE90000
1>
1>CONTEXT:
1> Eax = 00FE5678 Esp = 006FEE34
1> Ebx = 00FE55F8 Ebp = 006FEE60
1> Ecx = 00000080 Esi = 00FE55F8
1> Edx = 00000080 Edi = FEE90000
1> Eip = 0F20CC4E EFlags = 00010247
1> SegCs = 00000023 SegDs = 0000002B
1> SegSs = 0000002B SegEs = 0000002B
1> SegFs = 00000053 SegGs = 0000002B
1> Dr0 = 00000000 Dr3 = 00000000
1> Dr1 = 00000000 Dr6 = 00000000
1> Dr2 = 00000000 Dr7 = 00000000
如果我从上面的函数声明中删除 __declspec(dllexport),则不会发生这种情况。
有没有人有交叉编译 ARM 共享库的经验,并且可能知道如何解决这个问题?
解决方案
ARM什么的?
如果您正在为 ARM Windows 构建,那么它在树莓派上的 Win10 IoT 和 Windows Phone 上运行良好。但是我没有使用__declspec(dllexport)
,我使用模块定义文件来控制我的导出。设置是配置属性/链接器/输入/模块定义文件。有关更多信息,请参阅本文。
如果您正在为 ARM Linux 或 Android 或其他一些操作系统构建,我怀疑 VC++ 编译器是否支持该目标。改用 clang,它是 VS2017 的一个可选组件。
推荐阅读
- c++ - 如何将 shmat 与非 NULL 页面对齐的 shmaddr 一起使用?
- php - 为什么“PHP flush()”在 IOS 中不起作用?
- laravel - 我的搜索中只有字符的搜索栏
- openrefine - 在 OpenRefine 中,如何使用正则表达式查找/替换首字母?
- android - 在 ActionBar Kotlin 上实现下一个按钮
- javascript - ReactJS 从 div 数组更新 DIV
- java - 如何从 Firebase 中的实时数据库中检索数据?
- java - RecyclerView的加载时间问题
- sql - Invoke-SQLcmd:“@”附近的语法不正确。消息 102,级别 15,状态 1,程序,第 5 行
- java - Groovy 脚本中的 XMLSlurper 不适用于简单的 XML