开发者

Linux program in FreeBSD

Trying to run my program in FreeBSD OS, I have the following results:

$ ./myprogram

ELF binary type "0" not known

./myprogram: 1: Syntax error: "&" unexpected (expecting ")")

$ file myprogram

myprogram: ELF 32-bit LSB executable, Intel 80386, ver开发者_开发技巧sion 1 (SYSV), 

dynamically linked (uses shared libs), for GNU/Linux 2.6.15, 

not stripped

The program is built In GCC on Ubuntu computer. What can I do? Can I build the program for FreeBSD on my Ubuntu computer by changing some build options, or I need to build it in FreeBSD OS? Maybe there is some way to convert executable to format recognized by FreeBSD?


You can run a lot of Linux programs on FreeBSD, see http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/linuxemu.html.

If this doesn't work, the easiest solution would be to recompile your program on FreeBSD.


Try branding the executable as a linux executable using brandelf (you still need all the dependent libraries setup though, or try linking it statically

http://www.freebsd.org/cgi/man.cgi?query=brandelf&apropos=0&sektion=0&manpath=FreeBSD+8.0-RELEASE&format=html


2021-06-21: This answer is outdated. As of 2021, FreeBSD includes Linux® binary compatibility, which will run most Linux binaries, save for those which "overly use i386™ specific calls, as enabling virtual 8086 mode".


A large number of Linux programs can be compiled on BSD systems however they are not the same operating system. Linux and BSD are technically not binary compatible.

These days BSD ships with an ABI (Application Binary Interface) for Linux which will translate Linux sys-calls on the fly (Much how WINE operates). This will allow you to run Linux ELF binaries on BSD systems with a small performance penalty.

That being said, they are not the same operating system and your best bet would be to compile for the target system either by gaining access to it or using a method of cross compiling.


brandelf -t "Linux" and it should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜