首页 > 解决方案 > 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 共享库的经验,并且可能知道如何解决这个问题?

标签: c++visual-studiovisual-c++armcross-compiling

解决方案


ARM什么的?

如果您正在为 ARM Windows 构建,那么它在树莓派上的 Win10 IoT 和 Windows Phone 上运行良好。但是我没有使用__declspec(dllexport),我使用模块定义文件来控制我的导出。设置是配置属性/链接器/输入/模块定义文件。有关更多信息,请参阅本文

如果您正在为 ARM Linux 或 Android 或其他一些操作系统构建,我怀疑 VC++ 编译器是否支持该目标。改用 clang,它是 VS2017 的一个可选组件。


推荐阅读