Running linux applications on mac

Emulating Linux binaries under Mac OS X

How do I run Linux binaries under Mac OS X? Googling around I found a couple of emulators but none for running Linux binaries on a Mac. There are quite a few posts about running Mac OS X on Linux and that kind of stuff — but that’s the opposite of what I want to do. Update: Thanks for all the answers! I am fully aware of MacPorts and Fink or any of the other things; and no, I do not want any of these utilities, and I do not want any of the package managers, I prefer to compile things myself. I also have Parallels and could set up virtual machines and all that jazz. The only thing I want to do is to find a way to run a binary that I do not have the source code for and has been compiled for Linux, but I do not want to run it under Linux but under Mac OS X. Therefore my question about emulators.

If your just looking to run software from the *nix/POSIX world it will probably compile provided it doesn’t depend on OS specific libraries. Fink or MacPorts can help with this somewhat.

I can’t think of any software that’s available for Linux, but not for Mac (sadly, since I’m a Linux guy). Why are you looking for such a thing?

Great question! I too, have a piece of enterprise software that runs in Linux, but my development machine is a Mac. Hopefully someone comes up with a solution — emulation layer for Linux binaries on Mac.

7 Answers 7

Well there is a project introducing something like Linux’s binfmt_misc to OS X so now what you need is an ELF loader, a dynamic linker that can load both Mach-O and ELF, and some mechanism to translate Linux calls to OS X ones.

Just for inspiration, you can implement the dynamic linker in the fashion that it ignores filename extension — both libfoo.so.1 (as an Linux ELF) and libfoo.1.dylib (as an Mach-O) can be loaded so that OS X versions of system libraries can be reused so that you do not need to write a «hosted on OS X» libc.so and syscalls can be handled by an kext that translates Linux calls to OS X ones in kernel.

Or, in an more elegant way, implement a stripped down Linux kernel as a kext that makes the OS X kernel a dual-purpose. However that will require you to use two sets of libraries. (Binaries do not clash so it is largely okay)

Источник

Running Linux GUI Apps in Docker on Mac

Why would you want to run Linux apps in Docker on a Mac? Maybe there’s a Linux program you love or you want the added security of sandboxing an app. Or maybe, as was the case with me, you’re developing a C++ program targeting Linux and don’t want to cross compile your dependencies.

Читайте также:  Linux best developer distro

The following steps get the CLion IDE running in a Docker container created during the project’s build process. It uses XQuartz, a version of the X Window system that runs on macOS, along with socat.

  1. Download the Linux version of CLion
  2. Each time dependencies change, run create_dev_container.sh to create a Docker image and container. The script assumes ~/dev is your code directory. If you use something different, edit the script or run it as CODE_DIR= ./create_dev_container.sh
  3. Run start_dev_container.sh to start the container and exec bash inside of it
  4. From inside the container, run /home/dev/clion-XXX/bin/clion.sh to start CLion. If this fails, ensure your container contains a JRE by either manually running apt install default-jre or adding it to the Dockerfile.
  5. Either select «Evaluate for free» or enter your activation code
  6. Open your project
  7. Build it and enjoy code completion, etc.!
  8. If you make changes to settings they’ll be lost each time you create a new container. To save them, run docker cp my_project:/root/.CLionXXX/ ~/dev and import them next time you start CLion in a fresh container.

Источник

How to Install Linux Software on a Mac with MacPorts

MacPorts is a command-line package manager for macOS. If you’re familiar with apt-get or yum from Linux, then you know what a package manager does. It handles downloading, installing, updating and managing certain applications and their dependencies within macOS. With MacPorts you can install Linux applications on macOS from the command line.

What can I install?

Most of these applications are open-source, command-line utilities, but there are a fair share of “real” open-source, GUI-based applications. as well.

Like any package manager, MacPorts searches a library of downloadable software. When you find what you need, MacPorts downloads and installs the appropriate software and dependencies in the right place. This saves you the trouble of downloading repositories from GitHub and building software from source packages while still getting access to a wide range of Linux’s best command-line tools and GUI applications.

If you read our post on Homebrew, you know that macOS is missing some “standard” Linux terminal commands out of the box. Mac users won’t find common command-line tools like nmap or wget , and there’s no native package manager on the Mac to provide them. You can also use MacPorts to install open-source software like GIMP.

Installing MacPorts

MacPorts requires the latest version of Xcode for your OS version. You can download Xcode from the Mac App Store or Apple’s developer website.

install-linux-apps-mac-macports-xcode

While you can run most of the MacPort commands without Xcode, you won’t be able to run many of the packages until you install it.

Читайте также:  Easy anti cheat линукс

Installing Xcode Developer Tools

1. Open Terminal and use the command below to trigger the installation of macOS’ developer tools:

install-linux-apps-mac-macports-00001

2. Click “Install” in the pop-up box.

install-linux-apps-mac-macports-xcode-2

3. Wait for the files to download and install.

install-linux-apps-mac-macports-xcode-3

Installing the MacPorts Package

If you already have the Xcode and the developer tools installed, you can jump right to this step.

1. Download the latest release of MacPorts from GitHub. Make sure you scroll down to choose the version that matches your version of macOS. At the time of publication, there is no version of MacPorts for Apple’s newest OS, High Sierra.

install-linux-apps-mac-macports-install

2. Install the package from your Downloads folder.

3. Open a new Terminal window and run the command port.

install-linux-apps-mac-macports-00002

If that command returns “MacPorts 2.4.1” and provides a slightly different-looking command prompt, then you’re ready to rock!

Install Linux Apps with MacPorts

To install some Linux apps on macOS with MacPorts, we will first need to search for the relevant programs.

1. To see a gigantic list of all available packages, open Terminal, type port list and press Enter.

install-linux-apps-mac-macports-00003

install-linux-apps-mac-macports-00004

3. Obviously, that’s a lot to look through. We can use the port search command to find something specific. Let’s search for nmap using the command below:

install-linux-apps-mac-macports-00005

4. That returns a few matching packages. The first one, just called “nmap,” is the one we’re looking for.

install-linux-apps-mac-macports-00006

5. To get more information about that package we can use the info command:

install-linux-apps-mac-macports-00008

6. That returns some specific information about nmap. That all looks good, so we can install with the command below:

install-linux-apps-mac-macports-00009

Note the sudo prefix which will require your admin password to fire.

7. Depending on the package you’re installing, there might be a large list of dependencies. These are software packages that your desired port relies on, and you’ll need to install them alongside your port of choice. Type “Y” and press “Enter” to accept the installation.

install-linux-apps-mac-macports-00010

8. When the installation is complete, you can run the command as you would on Linux via Terminal.

macports-run-linux-command

Conclusion

MacPorts is a powerful package manager that will connect you to a huge array of open-source binaries and applications that you can download and install on demand. If you want to learn more of the application’s commands, you can check out the MacPorts Guide for more information.

Alexander Fox is a tech and science writer based in Philadelphia, PA with one cat, three Macs and more USB cables than he could ever use.

Our latest tutorials delivered straight to your inbox

Источник

Is there a way to run a Linux binary on macOS?

Is there a way to run a Linux binary in macOS? I tried to run a binary but it said it isn’t executable.

Well OS X does not use elf binaries, so it’s a bit like trying to run windows .exe. However, a brief search finds this: osxbook.com/software/xbinary If you can recompile your code, it’s not an issue.

Читайте также:  Pegatron ipppv d3g linux

XBinary requires a program that knows how to run your binary; it in and of itself doesn’t run anything.

@ott— You can use «wine» to run Windows binary on Linux. Maybe there is a wine-like thing to run Linux binary on macOS.

4 Answers 4

Update years later: The Noah repo has now been archived. I haven’t found a good alternative.

I recently starting using Noah to run Linux binaries in macOS. You can install using homebrew ( brew install linux-noah/noah/noah ). Then you should be able to do this:

In my experience the behavior of the binary matches what I see on my Ubuntu machine.

Outdated answer, it does not work anymore. noah has been removed from homebrew and the source code is archived.

These answers are half correct, because virtualization is a choice but there is another. May I present.

History

  1. First there was UNIX, circa 1972
  2. Then the Timeline Split
    • In 1977, for $90, Bob Fabry and others, compiled/built the first versions of BSD, short for Berkeley Systems Distribution.
    • In 1991, Linus Torvalds posted in a Newsgroup, about software he used from Richard Stallman, who started GNU in 1983, and Linus’es UNIX was born.
    • Apple reacquired NeXT Software in 1996, after Steve Jobs was fired from Apple in 1984, and used the software and people there to build OS X. OS X is the Darwin OS + the NeXT Desktop Environment. And now we’re back to Bullet #1, as Darwin is a closed source fork of BSD. For the Open Source Project, see PureDarwin. For the Official Apple Developer Page, see Apple Open Source.

How We Can Use This

BSD’s traditionally use the Ports system for Package Management. The most widely used of these are the FreeBSD Ports. Ports are packages installed directly from source. Since the same Linux applications come from the same sources, you can run a Linux application if its port exists. Don’t use these Ports on a Mac because.

Since all of Apple’s GUI’s are written using the Cocoa API — WikiEntry, bundled with XCode — OS X for Developers, the Ports can be tuned to take advantage of this:

  1. Install XCode for your version of OS X.
  2. Bundled inside XCode is Apple’s version of the GCC Compiler, and all the other associated tools. To update the tools, see this post on StackOverflow. The tools are OS Version dependant, ie they are not backwards compatible, to my knowledge (in short, don’t install XCode for 10.8 on 10.6, etc.)
  3. Having installed XCode you now have a compiler, and can head on over to the MacPorts page and browse for the port you need installed, after installing the MacPorts .pkg installer

Caveat

The ports system doesn’t necessarily do dependency checking, unless the port was well written. I lightly touched on the problem in what does elibc_FreeBSD mean in gentoo portage overlays?

Источник

Оцените статью
Adblock
detector