简体   繁体   English

在 linux 集群上运行 windows C++ 代码

[英]running windows C++ code on a linux cluster

My program recently got an bad_alloc error when increasing it's precision.我的程序最近在提高精度时遇到了bad_alloc错误。 My guess is, that it needs more RAM than my Computer can assign it (effectively more than 3GB RAM needed).我的猜测是,它需要的 RAM 比我的计算机可以分配的要多(实际上需要 3GB 以上的 RAM)。 So I decided to try it on our linux cluster since it can give me way more RAM.所以我决定在我们的 linux 集群上尝试一下,因为它可以给我更多的 RAM。 It contains some gcc modules.它包含一些 gcc 模块。 But I'm not sure how to use my c++ code on it.但我不确定如何在上面使用我的 c++ 代码。 Could I just run my.exe on the cluster or should I recompile it first on the linux cluster?我可以只在集群上运行 my.exe 还是应该先在 linux 集群上重新编译它?

Well, you definitely need to recompile your code on cluster, if I understood the situation correctly.好吧,如果我正确理解了情况,您肯定需要在集群上重新编译您的代码。 You have built your app on Windows platform, so that binary cannot work on linux target system.您已经在 Windows 平台上构建了您的应用程序,因此二进制文件无法在 linux 目标系统上运行。

There are ways to make Windows executables run on Linux, eg Wine but usually you want a native Linux executable.有一些方法可以使 Windows 可执行文件在 Linux 上运行,例如Wine ,但通常您需要一个本机 Linux 可执行文件。 Executables have a different file format on Windows ( EXE ) and on Linux ( ELF ).可执行文件在 Windows ( EXE ) 和 Linux ( ELF ) 上具有不同的文件格式。

Your options are你的选择是

  • to recompile the code and run the program without other tools or重新编译代码并在没有其他工具的情况下运行程序或
  • to use a tool, eg Wine, that can run Windows executables on Linux.使用可以在 Linux 上运行 Windows 可执行文件的工具,例如 Wine。

If your code can be compiled on a different system depends on your code.您的代码是否可以在不同的系统上编译取决于您的代码。 Did you use Windows libraries?您是否使用过 Windows 库? Did you use third party libraries?你用过第三方库吗? Did you use compiler extensions?您是否使用了编译器扩展?

Most third party libraries can usually be also used on Linux.大多数第三方库通常也可以在 Linux 上使用。 For Windows-only libraries and compiler extensions you have to find a workaround.对于仅限 Windows 的库和编译器扩展,您必须找到一种解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM