# [PC-BSD] Run linux binary files on PC-BSD



## btomza (Feb 8, 2013)

Hi All,

This question could be a bit simple, but really I don't know the answer.

I've tried to run some binary files (from linux) on PC-BSD, but I can't.
For example I want to run Sublime Text (http://www.sublimetext.com/), so I downloaded the files for linux, unzipped the files and I run it, but nothing happens, no errors, no messages, nothing.

I only see that a file is created after to run the binary file, the file is named "?L@8g?@8" with 0 bytes.

I've seen the same thing with other binary files, so my question: is there any way to run linux binary files? some workaround?

Thanks,
Alberto


----------



## SirDice (Feb 8, 2013)

[thread=7290]Topics about *PC-BSD* | FreeNAS | NAS4Free | m0N0WALL | pfSense | ArchBSD | kFreeBSD[/thread]


----------



## btomza (Feb 8, 2013)

Hi SirDice,

Thanks for your message!

Really, I know that, I know that the answer here could be a bit or totally different for FreeBSD and PC-BSD. But anyway, I've had good luck with the answers here, in general they apply very well; sure some times I need to do changes or "customize" the answer for my system, but in general (with my poor knowledge over FreeBSD or PC-BSD) they've helped a lot.

Anyway, thanks to tell it, I'll keep it in mind.


----------



## SirDice (Feb 8, 2013)

Not sure which one you downloaded but make sure to get the 32 bit version. There's currently no support for 64 bit Linux binaries (even on a 64 bit FreeBSD).


----------



## Terry_Kennedy (Feb 9, 2013)

btomza said:
			
		

> For example I want to run Sublime Text (http://www.sublimetext.com/), so I downloaded the files for linux, unzipped the files and I run it, but nothing happens, no errors, no messages, nothing.
> 
> I only see that a file is created after to run the binary file, the file is named "?L@8g?@8" with 0 bytes.
> 
> I've seen the same thing with other binary files, so my question: is there any way to run linux binary files? some workaround?


I don't have any experience with that software, but I do have a few suggestions. First, do you have the necessary Linux emulation module(s) loaded? You can check with kldstat(8):
	
	



```
(0:150) www2:/tmp# kldstat | grep linux
 4    1 0xffffffff80c12000 1f0fd    linux.ko
```

Note that linux.ko by itself may not be sufficient - there are other modules that provide optional pieces of Linux emulation.

Next, this looks like a graphics app. Do you have the requisite *Linux* versions of any dependencies (like X libraries) installed? Remember, a process doing Linux emulation thinks it is in Linux-land, and libraries, etc. have to be supplied in Linux format. It is only once things get into the kernel that the Linux syscalls are translated to FreeBSD kernel functions (and back on the return trip).

Last, if nothing else works you could try using ktrace(1) to see what's going on. This gives you a large (or huge) binary file which is interpreted by kdump(1). That doesn't give you visibility into the Linux program itself, but you can see all of its requests for libraries, system calls, etc. which might help pin down the problem. Or, it could be impenetrable gobbledygook, depending on how familiar you are with the system.


----------



## btomza (Feb 15, 2013)

Hi All,

Thanks about your answers.

As SirDice said the 64bit version doesn't work (and run it from console I could see a binary error), I tried with 32bit version, it was better.

With 32bit version I see the next errors:

```
./sublime_text: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./sublime_text)
./sublime_text: /lib/libc.so.6: version `GLIBC_2.11' not found (required by ./sublime_text)
```
anyway both files exist, so I guess that maybe they are incorrect version or I guess they are for 64bits because I have /usr/lib32/*, so my question is, do you know if there is any way to create something like a "symbolic link" only for the sublime folder to say if you want get /usr/lib/libstcd++.so.6 use ./libstcd++.so.6... something like that? Is it possible? .... (surely it isn't possible...)

Thanks,
Alberto


----------



## fonz (Feb 15, 2013)

btomza said:
			
		

> ./sublime_text: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by ./sublime_text)
> ./sublime_text: /lib/libc.so.6: version `GLIBC_2.11' not found (required by ./sublime_text)
> 
> anyway both files exist


You probably need the Linux versions of those. Have you checked in /compat/linux (e.g. /compat/linux/usr/lib and /compat/linux/lib) ?


----------



## kchoudhu (Feb 15, 2014)

I had to install the new linux_base-c6 port along with a set of ports patches from here to get this working: 

https://github.com/cpu82/skype4-ports

Once you merge in the tree from the link, the relevant ports are: 

emulators/linux-base-c6
x11/linux-c6-xorg-libs
x11-toolkits/linux-c6-pango
x11-toolkits/linux-c6-gtk2

Add the following to /etc/sysctl.conf: 


```
compat.linux.osrelease=2.6.18
```

And the following to your /etc/rc.conf (or equivalent): 


```
linux_enable="YES"
```

Bounce your machine, download the ST2 package, and it should work. For reference, I'm on a 10-RELEASE machine. 

Edit: As others have pointed out, you will need the 32-bit ST2 binary.


----------



## wblock@ (Feb 15, 2014)

There is no need for a separate rc.conf.local, and good reason to avoid one.  Just add the setting to /etc/rc.conf.


----------



## kchoudhu (Feb 15, 2014)

Sure, changed my post. Could I ask why rc.conf is superior?


----------



## kpa (Feb 15, 2014)

kchoudhu said:
			
		

> Sure, changed my post. Could I ask why rc.conf is superior?



That's the file you're going edit anyway so why not keep all settings in one file? The purpose of rc.conf.local is to have site local configuration settings that are common to every host in it (and by distributing a copy of it using for example net/rdist6). Unless you have multiple hosts that need to have such common settings you're better off just using rc.conf(5).


----------



## wblock@ (Feb 15, 2014)

/etc/rc.conf is the standard place to set options.  All the defaults for standard settings are read from /etc/defaults/rc.conf, and then overridden in rc.conf.


----------



## kchoudhu (Feb 15, 2014)

Thanks guys -- this is good to know. 

Also, kudos to whoever is building up the linux_base-c6 port. With ST2 and Skype now functioning on FreeBSD, I've been able to cut over to FreeBSD as my primary desktop.


----------



## gour (Feb 21, 2014)

kchoudhu said:
			
		

> I had to install the new linux_base-c6 port along with a set of ports patches from here to get this working:



I've similar requirement to run specific Linux binary (VueScan) and f10 is too old (missing GLIBC version etc.


emulators/linux-base-c6

I managed to install the above port in my jail on 10.0 and no more 'missing GLIBC...', but, of course, there is missing gtk2 & co.

x11/linux-c6-xorg-libs
x11-toolkits/linux-c6-pango
x11-toolkits/linux-c6-gtk2

However, attempt to install the above port(s) gives:


```
===>  linux-c6-xorg-libs-7.4 bsd.linux-rpm.mk test failed: the port should be used with compat.linux.osrelease=2.6.16, which is supported by FreeBSD 8 and above.
*** Error code 1

Stop.
make: stopped in /usr/ports/x11/linux-c6-xorg-libs
```

although I've the code below in my /etc/sysctl.conf: 


```
compat.linux.osrelease=2.6.18
```

Any hint what might be wrong and/or is there any ETA when will linux_base-c6 become completed and end in ports?


----------



## Terry_Kennedy (Feb 23, 2014)

gour said:
			
		

> ```
> the port should be used with compat.linux.osrelease=2.6.16, which is supported by FreeBSD 8 and above.
> ```
> ...
> ...


Is the second a typo or did you intend to use 2.6.18?



> Any hint what might be wrong and/or is there any ETA when will linux_base-c6 become completed and end in ports?


If the above typo isn't the cause of the problem, then remove that line from your /etc/sysctl.conf file and report back with what `sysctl compat.linux.osrelease` reports, *after* rebooting.

Either something else is changing that variable or FreeBSD 10 ships with a newer linuxulator that reports a different version. If the latter, opening a bug on the problematic ports would be useful, since a port without a specific BROKEN line in its Makefile should build on all currently-supported versions of FreeBSD.


----------



## gour (Feb 24, 2014)

Terry_Kennedy said:
			
		

> Is the second a typo or did you intend to use 2.6.18?


Well, afaik, linux_base-c6 requires:


```
compat.linux.osrelease=2.6.18
```
and it's stated here, isnt' it?


> If the above typo isn't the cause of the problem, then remove that line from your /etc/sysctl.conf file and report back with what `sysctl compat.linux.osrelease` reports, *after* rebooting.


The default is, of course:

```
compat.linux.osrelease=2.6.16
```
which is required for linux_base-f10.

Now I'm really confused why you're surprised with '2.6.18' & linux_base-c6?


----------

