# Linux Compatibility Layer Help



## markbsd (Nov 5, 2013)

I need to install the Linux compatibility layer as certain applications won't run, but I am unable to install it:


```
# [CMD]cd /usr/ports/emulators/linux_base-f10[/CMD]
/usr/ports/emulators/linux_base-f10 # [CMD]make install distclean[/CMD]
===>  linux_base-f10-10_7 linuxulator is not (kld)loaded.
*** [install] Error code 1

Stop in /usr/ports/emulators/linux_base-f10.
```

I don't know what to do to fix this. Any ideas?


----------



## SirDice (Nov 5, 2013)

markbsd said:
			
		

> ```
> ===>  linux_base-f10-10_7 linuxulator is not (kld)loaded.
> ```


[cmd=]kldload linux[/cmd]


----------



## markbsd (Nov 5, 2013)

Thanks, @SirDice. I did this, and `kldstat` shows it is loaded. I tried to `./execute` the Linux binary but it returned this error:


```
ELF interpreter /lib/ld-linux.so.2 not found
Abort trap
```

So, I'm not sure if this is right, but I'm performing `make install distclean` in the linux_base-f10 port now. I'm assuming this will install the abovementioned ld-linux.so.2 that is required?

Update: managed to install /usr/ports/emulators/linux_base-f10

Upon trying to execute the linux binary:


```
XPCOMGlueLoad error for file ../libxpcom.so:
libxul.so: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
```

`ldd` reveals this:


```
libpthread.so.0 => /lib/libpthread.so.0 (0x2808c000)
	libdl.so.2 => /lib/libdl.so.2 (0x280a7000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x280ac000)
	libm.so.6 => /lib/libm.so.6 (0x2819c000)
	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x281c5000)
	libc.so.6 => /lib/libc.so.6 (0x281d3000)
	/lib/ld-linux.so.2 (0x28068000)
```

How do I install these Linux libraries? Actually, I don't think I need to install them. Just copy them to /compat/linux, is this correct?

Hrm. This doesn't make sense, because trying to execute the file only returns an error that complains libxul.so isn't available. So why does `ldd` return everything but that file? Not sure what to do. Any ideas?


----------



## wblock@ (Nov 5, 2013)

What are you trying to run?  There are some ports that install the Linux versions of software: www/linux-firefox.


----------



## ondra_knezour (Nov 5, 2013)

libxul.so is Mozilla XUL library. I did not found single port for this library, but it is part of www/linux-firefox.

pkg_libchk from sysutils/bsdadminscripts can do deep library dependency inspection.

You may get better responses if you write which port or program are you trying to run.


----------



## markbsd (Nov 5, 2013)

I'm trying to run the Tor Browser Bundle file start-tor-browser, which launches tor, vidalia and then the default tor browser, and also trying to run the tor browser independently (custom firefox browser).

`./start-tor-browser` returns:


```
$ [CMD]./start-tor-browser[/CMD] 

Launching Tor Browser Bundle for Linux in /usr/home/tor-browser
./App/vidalia: error while loading shared libraries: libSM.so.6: cannot open shared object file: No such file or directory
Vidalia exited abnormally.  Exit code: 127
$
```

and `./firefox` returns


```
$ [CMD]./firefox[/CMD]
XPCOMGlueLoad error for file /usr/home/tor-browser/App/Firefox/libxpcom.so:
libxul.so: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
```

The tarball, which contained this, was downloaded directly from torproject.org and it says it is for Linux, Unix, BSD. So, it should work.

If it is more easily fixed, I am happy directly running the firefox (in the event fixing the start-tor-browser problem is harder to fix). In which case, it appears it is just libxul.so that I need, yes?

Do you think copying libxul.so from App/Firefox to /compat/linux will work? Which dir in /compat/linux, though?

Copying it to /compat/linux/lib didn't work. Not sure what to do!

I've asked for help at the TOR forum, but it's really dead. You'd think there'd be literally hundreds of thousands of people with experience running TOR on FreeBSD. Seems not.


----------



## jasmine (Nov 6, 2013)

To make torified Firefox run try

```
$ cd www/linux-firefox; make depends

$ tar xf [url=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/i386/os/Packages/glib2-2.22.2-2.fc12.i686.rpm]glib2-2.22.2-2.fc12.i686.rpm[/url]
$ tar xf [url=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/i386/os/Packages/gtk2-2.18.3-19.fc12.i686.rpm]gtk2-2.18.3-19.fc12.i686.rpm[/url]

# libs
$ cp lib/libgio-2.0.so.0 lib/libglib-2.0.so.0 usr/lib/libgdk-x11-2.0.so.0 usr/lib/libgtk-x11-2.0.so.0 tor-browser_en-US/App/Firefox/
$ sed -i '' /libxul/d tor-browser_en-US/App/Firefox/dependentlibs.list
$ printf "%s\n" libgio-2.0.so.0 libglib-2.0.so.0 libgdk-x11-2.0.so.0 libgtk-x11-2.0.so.0 libxul.so >> tor-browser_en-US/App/Firefox/dependentlibs.list

# avoid crash with plugins (e.g. flash)
$ mkdir tor-browser_en-US/App/Firefox/defaults/preferences/
$ echo 'pref("dom.ipc.plugins.enabled", false);' >> tor-browser_en-US/App/Firefox/defaults/preferences/browser-prefs.js
```

As Tor and Vidalia are unpatched in TBB their linux binaries can be replaced with equivalent ports.

```
# Tor depends on libevent2 which uses epoll on linux
# and not implemented in linuxulator but may still work
$ sed -i '' 's,\./tor,/usr/local/bin/tor,' tor-browser_en-US/Data/Vidalia/vidalia.conf
$ cd security/tor; make install

# Vidalia depends on Qt which needs GLIBC_2.10
$ sed -i '' 's,\./App/vidalia,/usr/local/bin/vidalia,' tor-browser_en-US/start-tor-browser
$ cd net-mgmt/vidalia; make install
```


----------



## markbsd (Nov 7, 2013)

[font=Arial]Okay, please let me see if I understand:

* Step 1*
*(a)* install firefox linux dependencies (as root or user)?

```
#[CMD]cd[/CMD] [FILE]www/linux-firefox[/FILE]; [cmd]make depends[/cmd]
```
*(b)* extract the following (what are these *.rpm files?) as root or user?

```
$ [CMD]tar xf[/CMD][FILE] [url=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/i386/os/Packages/glib2-2.22.2-2.fc12.i686.rpm]glib2-2.22.2-2.fc12.i686.rpm[/URL][/FILE]
$ [CMD]tar xf[/CMD] [FILE][url=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Everything/i386/os/Packages/gtk2-2.18.3-19.fc12.i686.rpm]gtk2-2.18.3-19.fc12.i686.rpm[/URL][/FILE]
```


*Step 2*
*(a)* copy the libraries to the tor browser bundle directory?

```
$ [CMD]cp[/CMD] [file]lib/libgio-2.0.so.0 lib/libglib-2.0.so.0 usr/lib/libgdk-x11-2.0.so.0 usr/lib/libgtk-x11-2.0.so.0 tor-browser_en-US/App/Firefox/[/file]
```
*(b)* what am I doing with the following commands?

```
$ [CMD]sed -i[/CMD] '' [file]/libxul/d tor-browser_en-US/App/Firefox/dependentlibs.list[/file]
$[CMD] printf[/CMD] "%s\n" libgio-2.0.so.0 libglib-2.0.so.0 libgdk-x11-2.0.so.0 libgtk-x11-2.0.so.0 libxul.so >> [file]tor-browser_en-US/App/Firefox/dependentlibs.list[/file]
```


*Step 3*
*(a)* configure plugins?

```
$ [CMD]mkdir[/CMD] [FILE]tor-browser_en-US/App/Firefox/defaults/preferences/[/FILE]
$ [CMD]echo[/CMD]'pref("dom.ipc.plugins.enabled", false);' >> [FILE]tor-browser_en-US/App/Firefox/defaults/preferences/browser-prefs.js[/FILE]
```


*Step 4*
*(a)* configure BSDs equivalent Linux binaries for Tor?

```
$ [CMD]sed -i[/CMD] '' 's,\./[FILE]tor,/usr/local/bin/tor,' tor-browser_en-US/Data/Vidalia/vidalia.conf[/FILE]
```
*(b)* install Tor with BSD binary equivalency?

```
$ [CMD]cd[/CMD] [FILE]security/tor[/FILE]; [cmd]make install[/cmd]
```
*(c)* configure BSDs equivalent Linux binaries for Vidalia?

```
$ [CMD]sed -i [/CMD]'' 's,\./[FILE]App/vidalia,/usr/local/bin/vidalia,' tor-browser_en-US/start-tor-browser[/FILE]
```
*(d)* install Vidalia with BSD binary equivalency?

```
$ [CMD]cd[/CMD] [FILE]net-mgmt/vidalia[/FILE]; [cmd]make install[/cmd]
```
[/font]


----------



## jasmine (Nov 7, 2013)

markbsd said:
			
		

> (what are these *.rpm files?)


Packages from Fedora 12 in the official archive (f12 is obsolete, too). emulators/linux_base-f10 and x11-toolkits/linux-f10-gtk2 as their name implies are packages from Fedora 10 with which recent Firefox and TBB releases no longer work.


			
				markbsd said:
			
		

> *Step 2*
> *(b)* what am I doing with the following commands?
> 
> ```
> ...


dependentlibs.list contains a list of libraries firefox uses in order to satisfy libxul.so dependencies. sed/printf add lines for glib2 and gtk2 libs just before libxul.so.

It's possible to write that with a single command:

```
$ sed -i '' '/libxul/i\
libgio-2.0.so.0\
libglib-2.0.so.0\
libgdk-x11-2.0.so.0\
libgtk-x11-2.0.so.0
' tor-browser_en-US/App/Firefox/dependentlibs.list
```


----------

