[vbox-dev] [Patch] Changes for building VirtualBox on OSX

Kalogrianitis Socratis socratisk at gmail.com
Tue Jun 20 06:47:13 GMT 2017


The instructions for building VirtualBox on an OSX system are (sorry to say it) anything but functional. They're several years old, severely outdated and simply not working.

I was about to fire an e-mail detailing the instruction for successfully building VirtualBox on OSX, but decided to make an article in the OSE section of the forums for comments. See: https://forums.virtualbox.org/viewtopic.php?f=10&t=83521 for the updated instructions. Please feel free to copy them and update the official VirtualBox wiki.

However... these instructions require four changes in the "configure" script, three mandatory, one optional.



Index: configure
===================================================================
--- configure	(revision 67459)
+++ configure	(working copy)
@@ -153,7 +153,7 @@
 LIBVPX="-lvpx"
 PKGCONFIG="`which_wrapper pkg-config`"
 PYTHONDIR="/usr /usr/local"
-QT5DIR="/usr/lib/qt5 /usr/share/qt5 /usr/lib64/qt5 /usr /usr/local"
+QT5DIR="/usr/lib/qt5 /usr/share/qt5 /usr/lib64/qt5 /usr /usr/local /opt/local/libexec/qt5"
 QT5DIR_PKGCONFIG=1
 QT5MAJ=5
 QT5MIN=6
@@ -1515,7 +1515,7 @@
     # Now try the user provided directory and some of the standard directories.
     QT_TRIES="$QT5DIR /System/Library /Library"
     for t in $QT_TRIES; do
-      if [ -f "$t/Frameworks/QtCore.framework/QtCore" ]; then
+      if [ -f "$t/lib/QtCore.framework/QtCore" ]; then
         PATH_SDK_QT5="$t"
         break
       fi
@@ -1523,8 +1523,8 @@
     # Add the necessary params for building the test application
     if [ -n "$PATH_SDK_QT5" ]; then
       foundqt5=1
-      INCQT5=-I$PATH_SDK_QT5/Frameworks/QtCore.framework/Headers
-      LIBQT5=-F$PATH_SDK_QT5/Frameworks
+      INCQT5=-I$PATH_SDK_QT5/lib/QtCore.framework/Headers
+      LIBQT5=-F$PATH_SDK_QT5/lib
       FLGQT5="-framework QtCore"
     else
       log_failure "Qt5 framework not found (can be disabled using --disable-qt)"
@@ -1605,9 +1605,9 @@
         if [ "$OS" = "darwin" ]; then
           # Successful build & run the test application so add the necessary
           # 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_INC" "$PATH_SDK_QT5/inc"
+          cnf_append "PATH_SDK_QT5_LIB" "$PATH_SDK_QT5/lib"
+          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



Explanation for the four changes:

1) The standard installation of MacPorts is in "/opt". The Qt5 toolkit is in "/opt/local/libexec/qt5". It makes sense to include that path in the standard/default search path, instead of using the "--with-qt-dir=/opt/local/libexec/qt5" directive. This is more of a ease of use change.

2, 3) I really don't know since when/why the "Frameworks" directory was there, but in a standard MacPorts installation, it's non-existent. Changes from the former to the latter, makes the whole thing work out of the box ("Frameworks" to "lib").

4) There is something not-right when the SDK, the lib, and the include path all point to the same path ("Frameworks"), which doesn't even exist. Pointing them to "qt5/", "qt5/lib" and "qt5/inc",  makes the whole thing work out of the box. Plus the "AutoConfig.kmk" actually looks better. From:

PATH_SDK_QT5_INC  := /opt/local/libexec/qt5/Frameworks
PATH_SDK_QT5_LIB  := /opt/local/libexec/qt5/Frameworks
PATH_SDK_QT5      := /opt/local/libexec/qt5/Frameworks
PATH_TOOL_QT5_BIN := /opt/local/libexec/qt5/bin

to

PATH_SDK_QT5_INC  := /opt/local/libexec/qt5/inc
PATH_SDK_QT5_LIB  := /opt/local/libexec/qt5/lib
PATH_SDK_QT5      := /opt/local/libexec/qt5
PATH_TOOL_QT5_BIN := /opt/local/libexec/qt5/bin


Now, if you want the documentation (UserManual.pdf) to be available in your custom build, you need to have the following "LocalConfig.kmk" in your source root directory. I believe that only the 1st directive is necessary, but the 2nd one might come in handy for distributing/packaging (haven't reached that "level" yet). Whether the documentation should be there, without the need for the LocalConfig's existence, it's a matter of debate. I personally favor including the documentation as the default option.

$ cat LocalConfig.kmk

VBOX_WITH_DOCS = 1
VBOX_WITH_DOCS_PACKING = 1




More information about the vbox-dev mailing list