如何为许多体系结构构建和测试一个C linux程序,而不为每个体系结构设置环境?

时间:2022-05-15 02:50:33

Suppose I've written a simple program in C. It builds and runs successfully on my primary arch.

假设我在c中编写了一个简单的程序,它在我的主拱上成功地构建和运行。

Now I want to find out on what architectures the program can be built and works; also provide pre-built executables for download for variety of platforms. However I have only few of them.

现在我想知道这个程序可以构建和工作的架构;还提供预构建的可执行文件,用于各种平台的下载。但是我只有几个。

The most obvious way seems to be set up maximum number of cross compiling tool chains and maximum number of executable images for different architectures. But this seems to be inconvenient (especially if you just want it for one little program).

最明显的方法似乎是为不同的体系结构设置最大交叉编译工具链数和最大可执行图像数。但这似乎不太方便(尤其是如果你只想要一个小程序的话)。

How to do it in a simple way? Should I use some on-line service which provides already set up for development systems for various architectures?

如何用简单的方法去做?我是否应该使用一些已经为各种体系结构的开发系统设置的在线服务?

Expecting something like this:

希望是这样的:

user$ ssh i386.buildhere.example
guest@i386 $ echo 'int main(){}' > hello.c
guest@i386 $ gcc hello.c -o hello
guest@i386 $ ./hello
guest@i386 $ file hello
hello: ELF 32-bit LSB executable, Intel 8038....
user$ ssh armel.buildhere.example
guest@armel $ ....

...

Additional bonus whould be if there are also various outdated systems availble to test "how my program would behave on that legacy distribution?".

如果还可以使用各种过时的系统来测试“我的程序在遗留发行版上将如何运行?”

1 个解决方案

#1


3  

There is one thing that is ALMOST certain in programming: Whatever you do to test something will probably work, but whatever you haven't tested will fail when you give it to a customer.

在编程中有一件事几乎是确定无疑的:无论您做什么测试,都可能成功,但是当您将未测试的东西交给客户时,它将失败。

Use of virtual machines will help to some degree to avoid having to buy unusual hardware, as does things like QEMU.

使用虚拟机在某种程度上将有助于避免购买不寻常的硬件,QEMU这样的东西也是如此。

Unless your program is either REALLY trivial, or you want to use your customers [1] as guinea-pigs, you are best off testing on every platform-type that you want to release for. If you don't, it WILL come back and bite you at some point.

除非您的程序非常琐碎,或者您希望将您的客户[1]用作豚鼠,否则最好在您想要发布的每个平台类型上进行测试。如果你不这样做,它会回来咬你一口。

If you don't, you run the risk of some of your customers gets an "unhappy experience". An unhappy customer tells ten people, a happy customer tells maybe one person.

如果你不这样做,你就有可能让你的一些客户获得“不愉快的体验”。一个不快乐的顾客告诉10个人,一个快乐的顾客告诉可能一个人。

If you wish to support architectures/stuff that you don't have access to, maybe just having a "help yourself" option of source-code is a better choice than downloadable binaries.

如果您希望支持无法访问的体系结构/内容,那么使用源代码的“帮助自己”选项可能比下载的二进制文件更好。

Of course, you can rent time/space on servers of various kinds - I looked into writing an iPhone app, and there are places that run Mac's as virtual machines on the net that you can rent for around US$ 15 per month, for example.

当然,你可以在各种各样的服务器上租用时间/空间——我曾研究过如何编写一个iPhone应用程序,还有一些地方把Mac作为虚拟机在网络上运行,你可以以每月15美元的价格租用这些服务器。

[1] Throughout this answer, by customer, I mean anyone that downloads your software, regardless of whether they actually give some money to anyone, they will have spent some effort to get your software on their machine. If it doesn't work, then they will be unhappy to some degree. How unhappy depends on a number of things, including how clear you made it that "this may not work" if you were to publish "untested" software.

[1]在这个答案中,顾客,我指的是任何下载你的软件的人,不管他们是否真的给了任何人一些钱,他们都会花一些精力把你的软件放到他们的机器上。如果不起作用,他们就会在某种程度上不开心。不满意的程度取决于很多事情,包括如果你要发布“未测试”的软件,你有多清楚地表明“这可能行不通”。

#1


3  

There is one thing that is ALMOST certain in programming: Whatever you do to test something will probably work, but whatever you haven't tested will fail when you give it to a customer.

在编程中有一件事几乎是确定无疑的:无论您做什么测试,都可能成功,但是当您将未测试的东西交给客户时,它将失败。

Use of virtual machines will help to some degree to avoid having to buy unusual hardware, as does things like QEMU.

使用虚拟机在某种程度上将有助于避免购买不寻常的硬件,QEMU这样的东西也是如此。

Unless your program is either REALLY trivial, or you want to use your customers [1] as guinea-pigs, you are best off testing on every platform-type that you want to release for. If you don't, it WILL come back and bite you at some point.

除非您的程序非常琐碎,或者您希望将您的客户[1]用作豚鼠,否则最好在您想要发布的每个平台类型上进行测试。如果你不这样做,它会回来咬你一口。

If you don't, you run the risk of some of your customers gets an "unhappy experience". An unhappy customer tells ten people, a happy customer tells maybe one person.

如果你不这样做,你就有可能让你的一些客户获得“不愉快的体验”。一个不快乐的顾客告诉10个人,一个快乐的顾客告诉可能一个人。

If you wish to support architectures/stuff that you don't have access to, maybe just having a "help yourself" option of source-code is a better choice than downloadable binaries.

如果您希望支持无法访问的体系结构/内容,那么使用源代码的“帮助自己”选项可能比下载的二进制文件更好。

Of course, you can rent time/space on servers of various kinds - I looked into writing an iPhone app, and there are places that run Mac's as virtual machines on the net that you can rent for around US$ 15 per month, for example.

当然,你可以在各种各样的服务器上租用时间/空间——我曾研究过如何编写一个iPhone应用程序,还有一些地方把Mac作为虚拟机在网络上运行,你可以以每月15美元的价格租用这些服务器。

[1] Throughout this answer, by customer, I mean anyone that downloads your software, regardless of whether they actually give some money to anyone, they will have spent some effort to get your software on their machine. If it doesn't work, then they will be unhappy to some degree. How unhappy depends on a number of things, including how clear you made it that "this may not work" if you were to publish "untested" software.

[1]在这个答案中,顾客,我指的是任何下载你的软件的人,不管他们是否真的给了任何人一些钱,他们都会花一些精力把你的软件放到他们的机器上。如果不起作用,他们就会在某种程度上不开心。不满意的程度取决于很多事情,包括如果你要发布“未测试”的软件,你有多清楚地表明“这可能行不通”。