[Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Discussions related to using the OSE version of VirtualBox.
cluelesscoder
Posts: 21
Joined: 27. Oct 2015, 19:41

[Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by cluelesscoder »


This topic is the continuation and the public discussion for the topic:
Howtos and Tutorials » Building VirtualBox » [HowTo] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9


Thanks! I wasted some time trying to follow the official instructions before I noticed this, altho I still haven't run through all the steps. What do you think about fixing the official instructions? Do you have write access to the repo and can you update the wiki?

I'm actually only interested in patching the documentation right now, but figured I'd pull down the code and maybe even try a hand at building the thing while doing so...
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Building VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by socratis »

cluelesscoder wrote:What do you think about fixing the official instructions? Do you have write access to the repo and can you update the wiki?
No, I don't have access, but the developers have been notified. Whether they make the changes is not up to me, although if I judge from the amount of queries about building VirtualBox on OSX, I'd say it's not a top priority. :?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: [HowTo] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by socratis »

Updated to include the 10.13 (HighSierra) version. It pretty much works like 10.12, with the XIP format still being the only drawback that Apple has decided to break the rules. Again...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Terobero
Posts: 3
Joined: 17. May 2018, 18:07

Downloading to Mac

Post by Terobero »

So I've been trying to download it for mac and its not working. First I've tried the directions in the official page, didn't work so i found this [HowTo] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9 (sorry can't paste links).

I've completed all steps but

Code: Select all

/Users/Shared/vbox/out/darwin.amd64/release/dist/loadall.sh
(the one before the last line).

I've tried to start the guide from start and realized I couldn't patch it

Code: Select all

svn patch ~/Patch_VirtualBox.diff /Users/Shared/vbox/
The error I get is this

Code: Select all

C         /Users/Shared/vbox/configure   (working copy)
>         rejected hunk @@ -153,7 +153,7 @@
>         rejected hunk @@ -1515,7 +1515,7 @@
>         rejected hunk @@ -1523,8 +1523,8 @@
>         rejected hunk @@ -1605,9 +1605,9 @@
Summary of conflicts:
  Text conflicts: 1
Last edited by socratis on 17. May 2018, 20:15, edited 1 time in total.
Reason: Fixed obfuscated URLs.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Downloading to Mac

Post by mpack »

The OS X your host or your guest?

Your language makes it seem like you are trying to install VirtualBox on an OS X host.

But to counter that, you posted in the "OS X Guests" forum.
Terobero
Posts: 3
Joined: 17. May 2018, 18:07

Re: Downloading to Mac

Post by Terobero »

Sorry, this forum is confusing. I am trying to install VirtualBox on Mac OS. Can you change the sub-forum?
Last edited by socratis on 17. May 2018, 20:15, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Downloading to Mac

Post by socratis »

I will merge your topic with the [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9 in the VirtualBox OSE section (Open Source Edition), because that's what you're trying to do; build VirtualBox from the source.

The "rejected hunk @@" from a quick search shows that it's a "git" message. I'm not sure why you ended up with "git", but VirtualBox uses "svn", and the instructions talk about "svn", not "git".
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Terobero
Posts: 3
Joined: 17. May 2018, 18:07

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by Terobero »

There are 2 more places I got errors that I didn't tell.

First is

Code: Select all

./configure --disable-hardening --with-xcode-dir=/Volumes/Xcode/Xcode.app
It says I don't have qt5 but I have installed it using both MacPorts and I also have downloaded the application QT. So I did --disable-qt at my first try but this might have caused the other error I am going to talk about.

Code: Select all

Checking for Qt5: 
  ** Qt5 framework not found (can be disabled using --disable-qt)!
The other error is at

Code: Select all

/Users/Shared/vbox/out/darwin.amd64/release/dist/loadall.sh
It says the destination does not have an Info.plist file.

Code: Select all

/Users/Shared/vbox/out/darwin.amd64/release/dist/VBoxDrv.kext has no Info.plist file.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by socratis »

@Terobero
One issue at the time, starting with the earliest one, because that one can cause the rest of failures. I'm trying to figure out why the patch doesn't work as is, and what needs to be done to get it properly. I'm a complete n00b on this, so it may take me some time to see what's going on...

You could do the patch by hand in the meantime. You have to do the patch by hand in the meantime!

Unless you get the "configure" part to go with no errors, there is absolutely no point in continuing. None.
Terobero wrote:It says I don't have qt5 but I have installed it using both MacPorts and I also have downloaded the application QT.
I'm not sure why you downloaded the Qt Application (what's that??? where did you get it from???) and what it does to the system, you may have two competing Qt installations and that could break things.

That's the first part you have to figure out, forget about the kext for now...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
barrykn
Posts: 13
Joined: 23. Apr 2019, 13:06

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by barrykn »

Compared to the "Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9" instructions, here's what I did differently to build VirtualBox (I tested this with VirtualBox 6.0.4 and 6.0.6, but not 6.0.8 yet):

If Java is not already installed, don't install it at the beginning. Instead, do it after installing MacPorts. (There's nothing really wrong with installing Java before MacPorts, but if you install MacPorts first, you can install Java as just another port, and that's the easiest/fastest way to do it.)

At some point, install the latest OpenSSL by doing something like the following example:

Code: Select all

tar zxf ~/Downloads/openssl-1.1.1b.tar.gz
cd openssl-1.1.1b
./config --prefix=/opt/openssl-1.1.1b --openssldir=/opt/openssl-1.1.1b/etc
make -j4
make test
sudo make install
(This is because I wasn't able to compile VirtualBox using any of the MacPorts versions of OpenSSL.)

Before installing any other ports, install an OpenSSL or LibreSSL port (openssl, openssl11, or libressl), if you haven't already done so. If you're only going to be using MacPorts for building VirtualBox, then just install the openssl port (the other ports will install faster that way, versus installing openssl11 or libressl). However, if you're going to need openssl11 or libressl instead of openssl, for some reason unrelated to building VirtualBox, now's the time to install it, before the openssl port gets automatically installed as a dependency for some other port.

Aside from openssl, I installed fewer ports because I didn't care about rebuilding the documentation. I installed:
pkgconfig (not explicitly installing pkgconfig caused other problems later on)
libidl
qt56
openjdk12 (to get Java)

(By the way, if you're going to install all the ports mentioned in "Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9", I think nowadays it should be OK to omit the "+universal" -- I think that has probably been unnecessary since OS X 10.9 became the minimum version for building VirtualBox. However, I haven't actually tested that yet.)

I downloaded the VirtualBox source from the Downloads page of the VirtualBox website, instead of using svn. (I'm not saying you shouldn't use svn, it's just that downloading the source tarball happened to be more convenient in my case.)

In addition to socratis's patch for the Qt stuff (which applied without problems for me), I had to patch something else as well: In Config.kmk, comment out the line that says "VBOX_WITH_DARWIN_R0_DARWIN_IMAGE_VERIFICATION = 1".

Since I installed my own OpenSSL, the config line becomes something like:
./configure --disable-hardening --with-xcode-dir=/Volumes/Xcode/Xcode.app --with-openssl-dir=/opt/openssl-1.1.1b

And with those changes to the directions, I was able to build and run VirtualBox from source on macOS 10.13.6.
paulroot
Posts: 4
Joined: 27. Aug 2019, 12:01

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by paulroot »

I am trying to build the VirtualBox 5.2.x on macOS High Sierra 10.13.6. I followed the guide as it is except I am using Homebrew instead of MacPorts.

Every thing compiles properly. But when it reaches on building GUI parts, it gives error that "Qt5 requires C++11 and yours doesn't seem to be".

I have installed gcc and given the path for gcc via --with-gcc and --with-g++.

But it is still using clang++ provided in Xcode toolchain provided via --with-xcode-dir.
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by socratis »

paulroot wrote:I followed the guide as it is except I am using Homebrew instead of MacPorts.
Then you didn't follow the guide! :)
I avoided Homebrew for a lot of reasons, but mainly because it doesn't provide the proper versions that are needed to replicate the VirtualBox setup. For example, you can only get Qt 5.13.x, not the Qt 5.6.3 that VirtualBox is built with.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
paulroot
Posts: 4
Joined: 27. Aug 2019, 12:01

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by paulroot »

socratis wrote: I avoided Homebrew for a lot of reasons, but mainly because it doesn't provide the proper versions that are needed to replicate the VirtualBox setup. For example, you can only get Qt 5.13.x, not the Qt 5.6.3 that VirtualBox is built with.
Thank you very much. Now I followed your guide on clean macOS High Sierra machine with Macports. That worked. :D
socratis
Site Moderator
Posts: 27330
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by socratis »

paulroot wrote:That worked.
It did??? :o :shock:
Because I haven't been able to build VirtualBox since Oct/2018, when they switched from OpenSSL 0.9.8 to 1.0.2 (or something like that), and I honestly haven't had the chance to test the instructions as per the post of "barrykn" (a couple of posts back), the latest of the problems been an impregnated battery (4 cm opening in the case), that wouldn't let me stress my MBP.

What revision are you using, (current) rev. 80012, 2019-07-26 18:43:23 +0300? And it builds with my instructions and MacPorts? Got to give it a shot, anew...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
paulroot
Posts: 4
Joined: 27. Aug 2019, 12:01

Re: [Discussion] Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9

Post by paulroot »

Yes. openssl gave me problem too. So here's what I did.

I downloaded the source code from Downloads section of VirtualBox. (VirtualBox-6.0.10.tar.bz2). Then installed Java and Macports as you suggested. Then I installed libidl, cdrtools, openssl, qt56 and subversion from Macports.

Updated configure file as you suggested.

Here openssl started giving errors

So I downloaded Homebrew, and installed openssl from there and ran configure command.

Code: Select all

./configure --disable-hardening --with-xcode-dir=/Volumes/Xcode/Xcode.app --with-openssl-dir=/usr/local/opt/openssl
Then it generated the env.sh. But running kmk gave error about pkg-config and quit. So, I installed pkgconfig from Macports. Now running configure gave error for libopus not found. Then, I installed opus via Homebrew. After that added /usr/local/bin, /usr/local/sbin and /usr/local/opt in the PATH variable.

After that I ran configure command

Code: Select all

./configure --disable-hardening --with-xcode-dir=/Volumes/Xcode/Xcode.app --with-openssl-dir=/usr/local/opt/openssl
and it worked.
Post Reply