My experience building VirtualBox from Subversion on Mojave

Discussions related to using the OSE version of VirtualBox.

My experience building VirtualBox from Subversion on Mojave

Postby DWPoon » 3. May 2019, 23:27

After some experimentation, I was able to build VirtualBox from Subversion r78203 on a macOS 10.14.4 (Mojave) host. I tried to follow the build instructions, and had to make a few tweaks to be able to build the code successfully. I hope to share my experience here, and also get someone to update the build instructions and the code.

  1. Because I'm using Homebrew instead of MacPorts, I had to do brew install libidl openssl pkg-config qt first. Also, I had to patch configure due to a difference in the location of the Qt plugins directory:

    Code: Select all   Expand viewCollapse view
    $ svn diff
    Index: configure
    ===================================================================
    --- configure   (revision 78203)
    +++ configure   (working copy)
    @@ -1592,7 +1592,7 @@
               # params to AutoConfig.kmk:
               cnf_append "PATH_SDK_QT5_INC" "$PATH_SDK_QT5/Frameworks"
               cnf_append "PATH_SDK_QT5_LIB" "$PATH_SDK_QT5/Frameworks"
    -          cnf_append "PATH_SDK_QT5" "$PATH_SDK_QT5/Frameworks"
    +          cnf_append "PATH_SDK_QT5" "$PATH_SDK_QT5"
               # Check for the moc tool in the Qt directory found & some standard
               # directories.
               for q in $PATH_SDK_QT5 /usr /Developer/Tools/Qt; do

  2. Furthermore, the following change to configure allows building on Mojave, and enables C++11 so that configure will not crash when validating the installation of Qt:
    Code: Select all   Expand viewCollapse view
    @@ -2192,6 +2192,15 @@
       test_header "Darwin version"
       darwin_ver=`uname -r`
       case "$darwin_ver" in
    +    18\.*)
    +      check_xcode_sdk_path "$WITH_XCODE_DIR"
    +      [ $? -eq 1 ] || fail
    +      darwin_ver="10.14" # Mojave
    +      sdk=$WITH_XCODE_DIR/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
    +      cnf_append "VBOX_WITH_MACOSX_COMPILERS_FROM_DEVEL" "1"
    +      cnf_append "VBOX_PATH_MACOSX_DEVEL_ROOT" "$WITH_XCODE_DIR/Developer"
    +      CXX_FLAGS='--std=c++11'
    +      ;;
         17\.*)
           check_xcode_sdk_path "$WITH_XCODE_DIR"
           [ $? -eq 1 ] || fail

  3. Since Xcode 10.2.1 does not come with MacOSX10.9.sdk, I had to use xcodelegacy to graft it from Xcode 6.4.
  4. Again, I had to enable C++11 to make it build:
    Code: Select all   Expand viewCollapse view
    Index: tools/kBuildTools/VBoxXcode62.kmk
    ===================================================================
    --- tools/kBuildTools/VBoxXcode62.kmk   (revision 78203)
    +++ tools/kBuildTools/VBoxXcode62.kmk   (working copy)
    @@ -91,7 +91,7 @@
     TOOL_VBoxXcode62_CDEFS            ?=
     
     TOOL_VBoxXcode62_CXXOBJSUFF       ?= .o
    -TOOL_VBoxXcode62_CXXFLAGS         ?=
    +TOOL_VBoxXcode62_CXXFLAGS         ?= --std=c++11
     TOOL_VBoxXcode62_CXXFLAGS.debug   ?= -g
     TOOL_VBoxXcode62_CXXFLAGS.profile ?= -O2 #-g -pg
     TOOL_VBoxXcode62_CXXFLAGS.release ?= -O2
    @@ -107,7 +107,7 @@
     TOOL_VBoxXcode62_OBJCDEFS         ?=
     
     TOOL_VBoxXcode62_OBJCXXOBJSUFF        ?= .o
    -TOOL_VBoxXcode62_OBJCXXFLAGS          ?=
    +TOOL_VBoxXcode62_OBJCXXFLAGS          ?= --std=c++11
     TOOL_VBoxXcode62_OBJCXXFLAGS.debug    ?= -g
     TOOL_VBoxXcode62_OBJCXXFLAGS.profile  ?= -O2 #-g -pg
     TOOL_VBoxXcode62_OBJCXXFLAGS.release  ?= -O2

  5. To fix the following compilation error…
    Code: Select all   Expand viewCollapse view
    src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp:1126:34: error: comparison between pointer and integer ('CFMutableDictionaryRef'
          (aka '__CFDictionary *') and 'io_object_t' (aka 'unsigned int'))
        AssertReturn(RefMatchingDict != IO_OBJECT_NULL, VERR_OPEN_FAILED);
                     ~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~


    I made the following change:
    Code: Select all   Expand viewCollapse view
    Index: src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp
    ===================================================================
    --- src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp   (revision 78203)
    +++ src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp   (working copy)
    @@ -1123,7 +1123,7 @@
          * this subject further right now. Maybe check this later.
          */
         CFMutableDictionaryRef RefMatchingDict = IOServiceMatching(kIOUSBDeviceClassName);
    -    AssertReturn(RefMatchingDict != IO_OBJECT_NULL, VERR_OPEN_FAILED);
    +    AssertReturn(RefMatchingDict, VERR_OPEN_FAILED);
     
         uint64_t u64SessionId = 0;
         uint32_t u32LocationId = 0;

  6. I had to disable System Integrity Protection by running csrutil disable in the Recovery OS.
  7. When loading kernel extensions using loadall.sh, I ran into the following error:
    Code: Select all   Expand viewCollapse view
    (kernel) kxld[org.virtualbox.kext.VBoxDrv]: The following symbols are unresolved for this kext:
    (kernel) kxld[org.virtualbox.kext.VBoxDrv]:    _g_abSUPBuildCert
    (kernel) kxld[org.virtualbox.kext.VBoxDrv]:    _g_cbSUPBuildCert
    (kernel) Can't load kext org.virtualbox.kext.VBoxDrv - link failed.
    (kernel) Failed to load executable for kext org.virtualbox.kext.VBoxDrv.
    (kernel) Kext org.virtualbox.kext.VBoxDrv failed to load (0xdc008016).
    (kernel) Failed to load kext org.virtualbox.kext.VBoxDrv (error 0xdc008016).
    Failed to load /Users/USER/devel/vbox/out/darwin.amd64/debug/dist/VBoxDrv.kext - (libkern/kext) link error.
    Check library declarations for your kext with kextlibs(8).


    To resolve that, I had to import a PKCS12-encoded key and certificate, with CN=MyTestCertificate, into my login keychain, and create a LocalConfig.kmk containing:

    Code: Select all   Expand viewCollapse view
    VBOX_SIGNING_MODE = test
    VBOX_CERTIFICATE_SUBJECT_NAME = MyTestCertificate

With these tweaks, I was able to build VirtualBox, load the kernel modules, and start the VirtualBox UI. I then run into an error when trying to start a VM, but that's another story.
DWPoon
 
Posts: 4
Joined: 2. Nov 2018, 19:37

Re: My experience building VirtualBox from Subversion on Mojave

Postby socratis » 5. May 2019, 09:53

DWPoon wrote:After some experimentation, I was able to build VirtualBox from Subversion r78203 on a macOS 10.14.4 (Mojave) host.
Excellent!!! That makes two of us (AFAIK)... 8)

DWPoon wrote:I tried to follow the build instructions, and had to make a few tweaks to be able to build the code successfully.
Muhahahaha... :P
I've been trying to get them to update the Wiki for ages, good luck with that... :roll:

I had the instructions written down in the "Build VirtualBox ≥ 5.1.2 on OSX ≥ 10.9" but I followed the MacPorts route, not the Homebrew one. I started making an attempt to have the whole thing with Homebrew, but it never came to fruition, I think that I'll reboot the whole process now. Mainly because since Oct/2018 and the move to OpenSSL 1.x.x, I've been unable to compile VirtualBox, it breaks in really funky ways (that's the reason for the Homebrew attempt) after r74295. But that would be the subject of another thread actually...

You'll see some of the modifications that you did to "configure" in my thread too... ;)

DWPoon wrote:2. Furthermore, the following change to configure allows building on Mojave, and enables C++11 so that configure will not crash when validating the installation of Qt
There's no other workaround for that? I got to check if these changes are valid for a 10.9 setup. Why 10.9 you ask? Because I have a MBP that's on 10.9.5 actually, and I use it as my "canary in the mine".

DWPoon wrote:3. Since Xcode 10.2.1 does not come with MacOSX10.9.sdk, I had to use xcodelegacy to graft it from Xcode 6.4.
Good one, I was not aware of that!

DWPoon wrote:5. To fix the following compilation error…
Hmm... makes me wonder why you had to modify "src/VBox/Devices/USB/darwin/USBProxyDevice-darwin.cpp", something's not right here, why would it compile for the VirtualBox team and not your setup?

My goal when writing the building instructions were to minimize the differences in the source code changes. Hoping that they would be included in the VirtualBox tree. No dice so far...

Having major changes in the source code should be a major no-no, and we should track down why it breaks and fix your setup/instructions.

DWPoon wrote:To resolve that, I had to import a PKCS12-encoded key and certificate ...
Did you try to build VirtualBox with the "--disable-hardening" option?

I've been working lately with "granada29" to bring a GUI to the "InstallerApp2ISO.sh", he's a really knowledgeable programmer and I think that if we bring him, and "andyp73" (another C guru) into the mix, we can finally get this thing going! :)


PS. I moved your thread from "OSX Hosts" to the "OSE" area.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
socratis
Site Moderator
 
Posts: 25971
Joined: 22. Oct 2010, 11:03
Location: Greece
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5

Re: My experience building VirtualBox from Subversion on Mojave

Postby DWPoon » 7. May 2019, 00:56

The kexts with the unresolved symbols were indeed built using configure with --disable-hardening.

As for the USBProxyDevice-darwin.cpp compilation error, I would guess that older versions of Clang treated the type mismatch as a warning, but the one bundled with Xcode 10.2.1 (Apple LLVM version 10.0.1 (clang-1001.0.46.4)) treats it as an error?
DWPoon
 
Posts: 4
Joined: 2. Nov 2018, 19:37


Return to VirtualBox OSE

Who is online

Users browsing this forum: No registered users and 1 guest