# GCC enabled by default on the virtualbox-ose-additions port!



## teo (Aug 14, 2018)

This generates errors when compiling that port to enable 3D graphics accelerator.


----------



## SirDice (Aug 14, 2018)

It looks like you're working with an old ports tree.


----------



## teo (Aug 14, 2018)

SirDice said:


> It looks like you're working with an old ports tree.


No, it is the new distribution of FreeBSD for 64 bits, I have it well updated, that port always generates problems  from previous versions. Because it depends on the GCC compiler and it gives an error at the end. The FreeBSD compiler is Clang, which conflicts with the *gcc* compiler.


```
$ uname -a
FreeBSD feb.com 11.2-RELEASE-p1 FreeBSD 11.2-RELEASE-p1 #0: Sun Aug  5 12:04:13 UTC 2018     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
$
```


----------



## SirDice (Aug 14, 2018)

What's in your /etc/make.conf?

The reason I think you're working with an old ports tree is because yours is showing GCC  6 when the current default GCC version is 7.  But that's besides the point, as far as I can tell the VirtualBox additions are built with Clang. At least mine is (and I do have 3D acceleration enabled).


----------



## teo (Aug 14, 2018)

SirDice said:


> What's in your /etc/make.conf?
> 
> The reason I think you're working with an old ports tree is because yours is showing GCC  6 when the current default GCC version is 7.  But that's besides the point, as far as I can tell the VirtualBox additions are built with Clang. At least mine is (and I do have 3D acceleration enabled).


Displaying the  /etc/ directory, those   make.conf file does not exist. As mentioned above, I have updated all ports


----------



## SirDice (Aug 14, 2018)

Can you post your copy of /usr/ports/emulators/virtualbox-ose-additions/Makefile?


----------



## kpa (Aug 14, 2018)

The GCC dependency is from devel/kBuild. It looks like you can turn the GCC option off if you want.


----------



## teo (Aug 14, 2018)

The only way to build that emulators/virtualbox-ose-additions port is to manually disable it from being enabled by default with that GCC dependency.
*#  * ee /usr/ports/emulators/virtualbox-ose-additions/Makefile


```
# Created by: Bernhard Froehlich <decke@bluelife.at>
# $FreeBSD: head/emulators/virtualbox-ose-additions/Makefile 476013 2018-07-31 18:41:30Z zeising $

PORTNAME=       virtualbox-ose
PORTVERSION=    5.2.16
PORTREVISION=   2
CATEGORIES=     emulators
MASTER_SITES=   http://download.virtualbox.org/virtualbox/${PORTVERSION}/
PKGNAMESUFFIX?= -additions
DISTNAME=       VirtualBox-${PORTVERSION}

MAINTAINER=     vbox@FreeBSD.org
COMMENT=        VirtualBox additions for FreeBSD guests

LICENSE=        GPLv2
LICENSE_FILE=   ${WRKSRC}/COPYING

BUILD_DEPENDS=  yasm:devel/yasm \
                kmk:devel/kBuild \
                xsltproc:textproc/libxslt

CPE_VENDOR=     oracle
CPE_PRODUCT=    vm_virtualbox

PATCHDIR=       ${.CURDIR}/../${PORTNAME}/files
WRKSRC=         ${WRKDIR}/VirtualBox-${PORTVERSION}
USE_RC_SUBR=    vboxguest vboxservice
USES=           compiler:c++11-lang cpe iconv kmod python:build tar:bzip2
ONLY_FOR_ARCHS= i386 amd64
MAKE_JOBS_UNSAFE=       yes

HAS_CONFIGURE=  yes
CONFIGURE_ARGS+=        --disable-alsa \
                        --disable-docs \
                        --disable-libvpx \
                        --disable-pulse \
                        --disable-python \
                        --disable-sdl-ttf \
                        --disable-xpcom
CONFIGURE_ARGS+=        --nofatal --with-gcc="${CC}" --with-g++="${CXX}"

CONFLICTS_INSTALL=      virtualbox-ose-[0-9]* \
                        virtualbox-ose-additions-devel-[0-9]* \
                        virtualbox-ose-devel-[0-9]* \
                        virtualbox-ose-legacy-[0-9]* \
                        virtualbox-ose-lite-[0-9]* \
                        virtualbox-ose-nox11-[0-9]*

OPTIONS_DEFINE= DBUS DEBUG OPENGL X11
OPTIONS_DEFAULT=        DBUS X11
OPTIONS_SUB=    yes

DBUS_CONFIGURE_OFF=     --disable-dbus
DBUS_LIB_DEPENDS=       libdbus-1.so:devel/dbus
OPENGL_CONFIGURE_OFF=   --disable-opengl

.include <bsd.port.options.mk>

.if ${SLAVE_PORT} == no
CONFLICTS_INSTALL+=     virtualbox-ose-additions-nox11-[0-9]*
.else
CONFLICTS_INSTALL+=     virtualbox-ose-additions-[0-9]*
.endif

.if ${PORT_OPTIONS:MOPENGL} && empty(PORT_OPTIONS:MX11)
BROKEN=         OPENGL requires X11 support. Run 'make config' again!
.endif

VIDEODIR=       ${PREFIX}/lib/xorg/modules/drivers
INPUTDIR=       ${PREFIX}/lib/xorg/modules/input

VBOX_BIN=       ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/additions
VBOX_SBINS=     VBoxControl \
                VBoxService \
                mount_vboxvfs

BUILD_WRKSRC=   ${VBOX_BIN}/src

KMK_BUILDTYPE=  release
KMK_CONFIG=     VBOX_LIBPATH_X11=${LOCALBASE}
KMK_FLAGS=

.if ${PORT_OPTIONS:MDEBUG}
KMK_FLAGS+=     BUILD_TYPE=debug
KMK_BUILDTYPE=  debug
MAKE_ARGS+=     DEBUG_FLAGS="-O1 -g"
.endif

.if ${PORT_OPTIONS:MOPENGL}
USE_XORG=       xcomposite xdamage xfixes
USE_GL=         gl
VBOX_LIBS=      VBoxEGL.so \
                VBoxOGL.so \
                VBoxOGLarrayspu.so \
                VBoxOGLcrutil.so \
                VBoxOGLerrorspu.so \
                VBoxOGLfeedbackspu.so \
                VBoxOGLpackspu.so \
                VBoxOGLpassthroughspu.so
.endif

.if ${PORT_OPTIONS:MX11}
BUILD_DEPENDS+= ${LOCALBASE}/libdata/pkgconfig/xorg-server.pc:x11-servers/xorg-server
RUN_DEPENDS+=   xrandr:x11/xrandr
USE_XORG+=      xorgproto x11 xcursor xext xmu xorg-server xrandr xt
USES+=          pkgconfig
VBOX_WITH_X11=  1
XORG_DRV_ABI=   pkgconf --modversion xorg-server | \
                ${SED} -E -e 's/\.[0-9]+$$//' -e 's/\.//'
.else
VBOX_WITH_X11=
.endif

.if ${ARCH} == i386
KMK_ARCH=       freebsd.x86
.else
KMK_ARCH=       freebsd.${ARCH}
.endif

.include <bsd.port.pre.mk>

.if ${COMPILER_TYPE} == clang
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-Config.kmk \
                ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-vboxvideo-Makefile.kmk \
                ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-x11include-xorg-server-1.17.1-compiler.h
.if ${COMPILER_FEATURES:Mlibc++}
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
.endif
.endif

post-patch:
        @${ECHO} 'VBOX_ONLY_ADDITIONS = 1' > ${WRKSRC}/LocalConfig.kmk
        @${ECHO} 'VBOX_WITH_DRAG_AND_DROP = ${VBOX_WITH_X11}' >> \
            ${WRKSRC}/LocalConfig.kmk
        @${ECHO} 'VBOX_WITH_DRAG_AND_DROP_GH = ${VBOX_WITH_X11}' >> \
            ${WRKSRC}/LocalConfig.kmk
        @${ECHO} 'VBOX_WITH_X11_ADDITIONS = ${VBOX_WITH_X11}' >> \
            ${WRKSRC}/LocalConfig.kmk
        @${ECHO} 'VBOX_GCC_std = -std=c++11' >> ${WRKSRC}/LocalConfig.kmk
.if ${COMPILER_TYPE} == clang
        @${REINPLACE_CMD} -e 's| -finline-limit=8000||' \
            -e 's| -fno-merge-constants||' \
            -e 's| -mpreferred-stack-boundary=2||' ${WRKSRC}/Config.kmk
.endif
        @${REINPLACE_CMD} -e 's|/usr/X11|${LOCALBASE}|g' \
            ${WRKSRC}/src/VBox/Additions/x11/VBoxClient/display.cpp
        @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
            ${WRKSRC}/Config.kmk ${WRKSRC}/configure \
            ${WRKSRC}/kBuild/header.kmk ${WRKSRC}/kBuild/units/qt4.kmk \
            ${WRKSRC}/kBuild/units/qt5.kmk ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \
            ${WRKSRC}/src/VBox/Additions/common/crOpenGL/load.c \
            ${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \
            ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop
        @${REINPLACE_CMD} \
            -e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' \
            ${WRKSRC}/configure
.if empty(ICONV_LIB)
        @${REINPLACE_CMD} -e 's|iconv||' ${WRKSRC}/Config.kmk \
            ${WRKSRC}/src/VBox/Runtime/Makefile.kmk \
            ${WRKSRC}/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
        @${ECHO} 'VBOX_ICONV_DEFS = LIBICONV_PLUG' >> ${WRKSRC}/LocalConfig.kmk
.endif

pre-build:
        cd ${WRKSRC} && ${SH} -c \
            '. env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS}'

do-install:
        ${MKDIR} ${STAGEDIR}${KMODDIR}
        ${INSTALL_KLD} ${VBOX_BIN}/src/vboxguest/vboxguest.ko \
            ${STAGEDIR}${KMODDIR}
        ${INSTALL_KLD} ${VBOX_BIN}/vboxvfs.ko ${STAGEDIR}${KMODDIR}
        ${INSTALL_LIB} ${VBOX_BIN}/pam_vbox.so ${STAGEDIR}${PREFIX}/lib
        ${INSTALL_PROGRAM} ${VBOX_SBINS:S|^|${VBOX_BIN}/|} \
            ${STAGEDIR}${PREFIX}/sbin/

do-install-DEBUG-on:
        ${INSTALL_KLD} ${VBOX_BIN}/src/vboxguest/vboxguest.ko.symbols \
            ${STAGEDIR}${KMODDIR}

do-install-X11-on:
        ${INSTALL_PROGRAM} ${VBOX_BIN}/VBoxClient ${STAGEDIR}${PREFIX}/bin/
        ${INSTALL_SCRIPT} \
            ${WRKSRC}/src/VBox/Additions/x11/Installer/98vboxadd-xclient \
            ${STAGEDIR}${PREFIX}/bin/VBoxClient-all
        # X11 autostart
        ${MKDIR} ${STAGEDIR}${PREFIX}/etc/xdg/autostart/
        ${INSTALL_DATA} \
            ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \
            ${STAGEDIR}${PREFIX}/etc/xdg/autostart/
        # KDE autostart
        ${MKDIR} ${STAGEDIR}${PREFIX}/share/autostart/
        ${INSTALL_DATA} \
            ${WRKSRC}/src/VBox/Additions/x11/Installer/vboxclient.desktop \
            ${STAGEDIR}${PREFIX}/share/autostart/
        ${MKDIR} ${STAGEDIR}${VIDEODIR}
        ${INSTALL_DATA} ${VBOX_BIN}/vboxvideo_drv_$$(${XORG_DRV_ABI}).so \
            ${STAGEDIR}${VIDEODIR}/vboxvideo_drv.so
        ${MKDIR} ${STAGEDIR}${INPUTDIR}
        ${INSTALL_DATA} ${VBOX_BIN}/vboxmouse_drv_$$(${XORG_DRV_ABI}).so \
            ${STAGEDIR}${INPUTDIR}/vboxmouse_drv.so

do-install-OPENGL-on:
        ${INSTALL_DATA} ${FILESDIR}/vboxvideo.conf \
            ${STAGEDIR}${PREFIX}/etc/libmap.d/
        ${INSTALL_DATA} ${VBOX_LIBS:S|^|${VBOX_BIN}/|} \
            ${STAGEDIR}${PREFIX}/lib/

.include <bsd.port.post.mk>
```


----------



## SirDice (Aug 14, 2018)

It's not emulators/virtualbox-ose-additions that depends on GCC.


```
USES=           compiler:c++11-lang cpe iconv kmod python:build tar:bzip2
```
This says it's going to use c++11-lang for compiler. According to /usr/ports/Mk/Uses/compiler.mk it's:

```
# c++11-lang:   The port needs a compiler understanding C++11
```
Which, unless forced otherwise, ends up being the base Clang. 

Take note of kpa's remark though, it's devel/kBuild that requires GCC. But this is a _build_ dependency. So, while it may require GCC to _build_ it, GCC is not required to _run_ it.


----------



## Vandopsis (Mar 21, 2022)

This is a four years old thread, but it seems that I have stumbeld upon this very problem.
I find it a bit strange, since probably the first thing one wants to do after installing FreeBSD on Virtual box is getting the additions. And it doesn't work.

FreeBSD pristine installation in virtualbox - following instructions: make in virtualbox-ose-additions
this is what I get:


```
===>   virtualbox-ose-additions-5.2.44_3 depends on executable: yasm - found
===>   virtualbox-ose-additions-5.2.44_3 depends on executable: kmk - not found
===>   kBuild-0.1.9998_13 depends on package: gmake>=4.3 - found
===>   kBuild-0.1.9998_13 depends on file: /usr/local/bin/makeinfo - found
===>   kBuild-0.1.9998_13 depends on executable: gcc9 - not found
===>  Installing for gcc9-9.3.0_1
===>  Checking if gcc9 is already installed
===>   Registering installation for gcc9-9.3.0_1 as automatic
pkg-static: cannot load keyword from /usr/ports/Keywords/postexec.ucl: No such file or directory
pkg-static: unknown keyword postexec: @postexec
pkg-static: cannot load keyword from /usr/ports/Keywords/postunexec.ucl: No such file or directory
pkg-static: unknown keyword postunexec: @postunexec
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/lang/gcc9
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/lang/gcc9
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/devel/kBuild
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/devel/kBuild
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/emulators/virtualbox-ose-additions
*** Error code 1

Stop.
make: stopped in /usr/ports/emulators/virtualbox-ose-additions
```


I do not even understand what this Keyword thing is.
kbuild has a dependency on gcc. Where and how eliminate it? And even if gcc is not the default compiler, _why it doesn't install_.. Isn't this strange?


----------



## grahamperrin@ (Mar 22, 2022)

Vandopsis said:


> FreeBSD



Which version, exactly?

`freebsd-version -kru ; uname -aKU`


----------



## SirDice (Mar 22, 2022)

Vandopsis said:


> I find it a bit strange, since probably the first thing one wants to do after installing FreeBSD on Virtual box is getting the additions. And it doesn't work.


Update your ports tree.


----------

