为什么我的 Linux 编译的二进制文件在 Windows 上运行时不起作用? [英] Why does my Linux-compiled binary not work when I run it on Windows?

查看:33
本文介绍了为什么我的 Linux 编译的二进制文件在 Windows 上运行时不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 C++ 和 Gtkmm 的非常简单的代码:

I have a really easy code using C++ with Gtkmm :

#include <gtkmm.h>

int main(int argc, char *argv[]){
Gtk::Main app(argc, argv);
Gtk::Window window;
Gtk::Main::run(window);
return EXIT_SUCCESS;
}

我在 Linux 上编译了它,我可以执行它是完美的.但问题是当我复制过去的可执行文件时,我无法在 Windows 上运行.但是我一直觉得 Gtkmm 是便携的?!

I compile this on Linux and It is perfect I can execute it. But the problem is when I copy past the executable I don't achieve to make workable on Windows. But I always think Gtkmm is portable ?!

我该如何解决这个问题?

How can I solve this problem ?

非常感谢!

推荐答案

Gtkmm 确实是一个可移植的实现.然而,您不能简单地将可执行文件从 Linux 复制并粘贴到 Windows.您必须为运行它的每个平台编译一次程序.在您的情况下,您必须为 Windows 创建典型的 .exe 可执行文件.

Gtkmm is indeed a portable implementation. Nevertheless you cannot simply copy and paste an executable from Linux to Windows. You have to compile your program once for each platform you're running it on. In your case, you have to create the typical .exe executable for Windows.

如果您想交叉编译 Windows 的可执行文件(即使用您的 Linux 机器为 Windows 创建 .exe 文件),请查看 mingw编译器工具链.这个博客可能也有一些有趣的为您提供信息.

If you want to cross-compile the executable for Windows (i.e. use your Linux machine to create the .exe file for Windows), have a look at the mingw compiler toolchain. This blog might also have some interesting information for you.

这篇关于为什么我的 Linux 编译的二进制文件在 Windows 上运行时不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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