My experience building VirtualBox from Subversion on Mojave
Posted: 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.
- 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
$ 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
- 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
@@ -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
- Since Xcode 10.2.1 does not come with MacOSX10.9.sdk, I had to use xcodelegacy to graft it from Xcode 6.4.
- Again, I had to enable C++11 to make it build:
Code: Select all
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
- To fix the following compilation error…
I made the following change:
Code: Select all
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); ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
Code: Select all
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;
- I had to disable System Integrity Protection by running csrutil disable in the Recovery OS.
- When loading kernel extensions using loadall.sh, I ran into the following error:
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
(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).
Code: Select all
VBOX_SIGNING_MODE = test VBOX_CERTIFICATE_SUBJECT_NAME = MyTestCertificate