1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'General' started by btomza, Feb 8, 2013.

  1. btomza

    btomza New Member

    Messages:
    14
    Likes Received:
    0
    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
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,392
    Likes Received:
    7
    [thread=7290]Topics about PC-BSD | FreeNAS | NAS4Free | m0N0WALL | pfSense | ArchBSD | kFreeBSD[/thread]
     
  3. btomza

    btomza New Member

    Messages:
    14
    Likes Received:
    0
    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.
     
  4. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,392
    Likes Received:
    7
    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).
     
  5. Terry_Kennedy

    Terry_Kennedy Member

    Messages:
    552
    Likes Received:
    0
    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):
    Code:
    (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.
     
  6. btomza

    btomza New Member

    Messages:
    14
    Likes Received:
    0
    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:
    Code:
    ./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
     
  7. fonz

    fonz Moderator Staff Member Moderator

    Messages:
    2,438
    Likes Received:
    5
    You probably need the Linux versions of those. Have you checked in /compat/linux (e.g. /compat/linux/usr/lib and /compat/linux/lib) ?
     
  8. kchoudhu

    kchoudhu New Member

    Messages:
    10
    Likes Received:
    0
    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:

    Code:
    compat.linux.osrelease=2.6.18
    
    And the following to your /etc/rc.conf (or equivalent):

    Code:
    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.
     
  9. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,209
    Likes Received:
    15
    There is no need for a separate rc.conf.local, and good reason to avoid one. Just add the setting to /etc/rc.conf.
     
  10. kchoudhu

    kchoudhu New Member

    Messages:
    10
    Likes Received:
    0
    Sure, changed my post. Could I ask why rc.conf is superior?
     
  11. kpa

    kpa Member

    Messages:
    4,008
    Likes Received:
    9
    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).
     
  12. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,209
    Likes Received:
    15
    /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.
     
  13. kchoudhu

    kchoudhu New Member

    Messages:
    10
    Likes Received:
    0
    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.
     
  14. gour

    gour New Member

    Messages:
    29
    Likes Received:
    0
    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:

    Code:
    ===>  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:

    Code:
    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?
     
  15. Terry_Kennedy

    Terry_Kennedy Member

    Messages:
    552
    Likes Received:
    0
    Is the second a typo or did you intend to use 2.6.18?

    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.
     
  16. gour

    gour New Member

    Messages:
    29
    Likes Received:
    0
    Well, afaik, linux_base-c6 requires:

    Code:
    compat.linux.osrelease=2.6.18
    
    and it's stated here, isnt' it?
    The default is, of course:
    Code:
    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?