[英]Compiling C Program on OS X to Run on Linux
I have a pretty simple C program that does some cryptographic calculations using only standard library functions. 我有一个非常简单的C程序,只使用标准库函数进行一些加密计算。
I will be running the program on Ubuntu (10.04, 32 bit) and compiled it on OS X 10.6 using cc with the -m32 flag. 我将在Ubuntu(10.04,32位)上运行该程序,并使用带有-m32标志的cc在OS X 10.6上编译它。 When I tried to run it on Ubuntu I got the error message "cannot execute binary file."
当我试图在Ubuntu上运行它时,我收到错误消息“无法执行二进制文件”。
When I compile it on Ubuntu it runs fine. 当我在Ubuntu上编译它时运行正常。
Is there any easy way to compile code on OS X into a binary that will run on Ubuntu? 有没有简单的方法将OS X上的代码编译成可在Ubuntu上运行的二进制文件? If not, what are the differences that cause the binary to be incompatible?
如果没有,导致二进制文件不兼容的区别是什么?
You need to set up a cross compiler. 您需要设置交叉编译器。 Using the GNU toolchain, the process looks something like this:
使用GNU工具链,该过程看起来像这样:
I've never tried OSX as a host OS, so I don't know if there are any other complications, but this is the general approach. 我从来没有尝试过OSX作为主机操作系统,所以我不知道是否还有其他任何复杂情况,但这是一般方法。 I'm working from memory, so add a comment if you need more help.
我正在从记忆中工作,所以如果你需要更多的帮助,请添加评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.