简体   繁体   English

仅适用于Linux的g ++跨平台编译

[英]g++ compiling for linux only cross-platform

I'm interested in setting up a remote server to run some intensive computations. 我对设置远程服务器以运行一些密集的计算感兴趣。 For various reasons, I might want to run a different linux distro than that of my dev box. 由于各种原因,我可能想运行一个与我的开发箱不同的Linux发行版。 Assuming the hardware is properly target, and I limit myself to ISO C libraries, can expect any problems running an executable on a linux distribution different from that which the code is g++-compiled? 假设硬件是正确的目标,并且我将自己限制在ISO C库中,那么在Linux发行版上运行与g ++编译的代码不同的可执行文件时,会遇到任何问题吗?

In my specific case, my dev box is latest Ubuntu-based. 在我的特定情况下,我的开发箱是最新的基于Ubuntu的。 Is there any linux distro on which the Ubuntu-based g++-compiled code will get hung up? 是否有任何Linux发行版可以挂起基于Ubuntu的g ++编译的代码? When selecting the remote server distro, what should I look for that will ensure trouble free operation? 选择远程服务器发行版时,我应该寻找什么来确保无故障运行?

I run a lot of computationally intense code that I've developed for my work on both my laptop and a desktop. 我在笔记本电脑和台式机上运行了大量为我的工作而开发的计算密集型代码。 Until I recently had to replace my laptop, it was a much slower machine with much less RAM than my desktop, so it was a similar situation to what you describe. 直到最近我不得不更换笔记本电脑之前,它是一台速度较慢的计算机,其内存比台式机少得多,因此与您所描述的情况类似。

If your code is computationally intense, you're likely going to want it to be optimized for whatever machine it is running on, whether that be your dev box or the remote server. 如果您的代码计算量很大,那么您可能希望针对正在运行的任何计算机(无论是开发箱还是远程服务器)对其进行优化。 I think the easiest thing to do would be to setup a makefile for your code, so that you can copy the makefile and the source over to the remote server, then as long as both the dev box and server the same version of gcc and any other library dependencies your code needs, you should simply have to issue the make command to build the code on the remote server. 我认为最简单的方法是为代码设置一个makefile,以便可以将makefile和源代码复制到远程服务器上,然后只要dev框和服务器都使用相同版本的gcc以及任何您的代码需要其他库依赖项,则只需发出make命令即可在远程服务器上构建代码。 If you need a quick tutorial on makefiles, this one was helpful for me when I first started using them. 如果您需要有关makefile的快速教程,当我第一次开始使用它们时, 对我很有帮助。

The benefit of doing things this way is that you can develop and test the code on one computer using a smaller data set, lower resolution grid, or whatever you need to do to reduce the computational intensity. 用这种方式做事的好处是,您可以在一台计算机上使用较小的数据集,较低的分辨率网格或进行任何减少计算强度的操作来开发和测试代码。 Then once you know its working, transfer it over to a more powerful machine to actually run the more intense version. 然后,一旦知道它的工作原理,就可以将其转移到功能更强大的计算机上,以实际运行更强大的版本。 By calling the make command, g++ can then use flags like -march=native or -mtune=native to ensure the code is optimized for the CPU of the remote server, and since it was compiled on that machine, you shouldn't have to worry about whether the executable built on one computer can just run on another one. 通过调用make命令,g ++随后可以使用-march=native-mtune=native类的标志来确保代码针对远程服务器的CPU进行了优化,并且由于它是在该计算机上编译的,因此您不必担心在一台计算机上构建的可执行文件是否只能在另一台计算机上运行。

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

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