用cmake交叉编译。我应该从交叉编译中期待什么
我还希望我为Linux开发的代码能够在Windows上使用。我为此写了简单的Hello World代码。我能够使用cmake使用mingw创建.exe文件。当我直接在Windows上运行.EXE文件时,即使它存在于我的计算机上,也会收到“ Libstdc ++ -6.dll”的错误。当我在Windows中删除 /build文件夹的内容并使用CMake构建时,新创建的.EXE文件工作了。当我不使用CMAKE直接使用MingW编译时,.EXE毫无问题地工作。 将.EXE文件及其源代码传输到Windows环境并期望直接工作是错误的吗?我想正确理解这个概念的逻辑。
I also want the code I developed for Linux to work on Windows. I wrote simple Hello world code for this. I was able to create the .exe file with minGW using Cmake. When I run the .exe file directly on Windows, I got the error "libstdc++-6.dll not found" even though it exists on my computer. When I deleted the contents of the /build folder in Windows and built it with Cmake, the newly created .exe file worked. When I compile directly with minGW without using Cmake, the .exe worked without problems.
Is it a mistake to transfer the .exe file with its source codes to the Windows environment and expect it to work directly? I want to understand the logic of this concept properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用不属于Windows本身的库,则通常需要在与EXE同一目录中为这些库的DLL分发DLL,以便您的EXE在另一台计算机上工作。
另外,许多交叉编译器支持
static
参数,您可以在链接时间传递,以便将这些库将这些库链接到您的可执行文件中。我赞成这种方法,但是对此的许可要求更为严格。(确保您遵循您重新分发不是您自己的,开源或其他方式的任何软件的许可条款。)
If you use libraries that are not part of Windows itself, you will generally need to distribute the DLLs for those libraries in the same directory as the EXE in order for your EXE to work on another computer.
Alternatively, many cross-compilers support a
-static
argument that you can pass at link time in order to statically link these libraries into your executable. I favor that approach, but the licensing requirements for it are stricter.(Make sure you follow the license terms for any software you redistribute that isn't your own, open source or otherwise.)