Build QT 5.2.0 on FreeBSD from source



  • Hello.
    When I configured Qt:
    @./configure -developer-build -opensource -nomake examples -nomake tests@

    I get error:
    @...
    g++ -c -o qdatetime.o -pipe -g -g -DQMAKE_OPENSOURCE_EDITION -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/library -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/generators -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/generators/unix -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/generators/win32 -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/generators/mac -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/qmake/generators/integrity -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/include -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/include/QtCore -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/include/QtCore/5.2.0 -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/include/QtCore/5.2.0/QtCore -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/src/corelib/global -DHAVE_QCONFIG_CPP -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/mkspecs/freebsd-g++ -I/usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/tools/shared -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY /usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/src/corelib/tools/qdatetime.cpp
    /usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/src/corelib/tools/qdatetime.cpp: In function 'int qt_timezone()':
    /usr/home/user/qt-everywhere-opensource-src-5.2.0/qtbase/src/corelib/tools/qdatetime.cpp:2194: error: invalid conversion from 'char* (*)(int, int)' to 'int'
    gmake: *** [qdatetime.o] Error 1
    @

    I have all requirements:
    @# pkg_info | grep python
    python-2.7_1,2 The "meta-port" for the default version of Python interpret
    python2-2_1 The "meta-port" for version 2 of the Python interpreter
    python27-2.7.5_4 Interpreted object-oriented programming language

    pkg_info | grep perl

    perl5.14-5.14.4_2 Practical Extraction and Report Language

    pkg_info | grep gcc

    gcc-4.6.4 GNU Compiler Collection 4.6
    gcc-ecj-4.5 Eclipse Java Compiler used to build GCC Java
    @


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    I think you should rather ask this question on the interest mailing list, I'm not really sure you'll find much user here compiling on BSD



  • [quote author="SGaist" date="1387399306"]Hi and welcome to devnet,

    I think you should rather ask this question on the interest mailing list, I'm not really sure you'll find much user here compiling on BSD[/quote]

    I did it. But not succesfully - xcb don't compiling.

    I use Qt on FreeBSD since 4.7.4 version.



  • Problem is in time.h

    On Linux, timezone defined as integer variable, but in FreeBSD as function

    char * timezone(int, int)

    I don't know how to solve this ((



  • I did it. But not succesfully – xcb don’t compiling.

    Because someone hardcoded -ldl in xcb's project file. Remove it.
    -ldl is never supposed to be hardcoded in project files, it is supposed
    to be dragged in by the Qmake specs on those platforms that really
    need this library. (There are also platforms where it is named -ldld).

    I don’t know how to solve this ((

    Using that "timezone" variable is a crock anyway. The correct way
    were to use tm_gmtoff from struct tm:

    @
    --- qtbase/src/corelib/tools/qdatetime.cpp~ 2013-12-08 18:09:52.000000000 +0100
    +++ qtbase/src/corelib/tools/qdatetime.cpp 2014-01-12 21:47:45.000000000 +0100
    (at)(at) -2190,6 +2190,13 (at)(at)
    long offset;
    _get_timezone(&offset);
    return offset;
    +#elif defined(__POSIX_VISIBLE) && !defined(__linux)

    •    time_t dummy = (time_t)0;
      
    •    struct tm *p = localtime(&dummy);
      
    •    return -p->tm_gmtoff;   // tm_gmtoff uses positive values east
      
    •                            // of UTC, but historic "timezone"
      
    •                            // variable used positive values west
      
    •                            // of UTC.
      

    #else
    return timezone;
    #endif // Q_OS_WIN
    @

    I also needed an #include <sys/utsname> in order to use
    uname(3) correctly:

    @
    --- qtbase/src/corelib/io/qfileselector.cpp~ 2013-12-08 18:09:53.000000000 +0100
    +++ qtbase/src/corelib/io/qfileselector.cpp 2014-01-13 08:40:52.000000000 +0100
    (at)(at) -51,6 +51,18 (at)(at)
    #include <QtCore/QLocale>
    #include <QtCore/QDebug>

    +#if defined(Q_OS_UNIX)
    +# if defined(Q_OS_LINUX_ANDROID)
    +# elif defined(Q_OS_BLACKBERRY)
    +# elif defined(Q_OS_QNX)
    +# elif defined(Q_OS_IOS)
    +# elif defined(Q_OS_LINUX)
    +# elif defined(Q_OS_MAC)
    +# else
    +# include <sys/utsname.h>
    +# endif
    +#endif

    QT_BEGIN_NAMESPACE

    //Environment variable to allow tooling full control of file selectors
    @

    Still, I didn't succeed completely. My current stop is here:

    @
    /usr/local/qt5/src/qt-everywhere-opensource-src-5.2.0/qtbase/lib/libQt5PlatformSupport.a(qevdevmousemanager.o): In function QEvdevMouseManager::QEvdevMouseManager(QString const&, QString const&, QObject*)': /usr/local/qt5/src/qt-everywhere-opensource-src-5.2.0/qtbase/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp:94: undefined reference toQDeviceDiscovery::create(QFlagsQDeviceDiscovery::QDeviceType, QObject*)'
    @

    (Replace the "(at)" strings in the patches by "at" signs. There
    doesn't appear to be a way to have those signs as part of a code
    block here.)



  • (I dropped my previous account, as my original one has been recovered now.)

    The QDeviceDiscovery stuff requires this patch:

    @
    --- ./qtbase/src/platformsupport/devicediscovery/devicediscovery.pri~ 2013-12-08 18:09:47.000000000 +0100
    +++ ./qtbase/src/platformsupport/devicediscovery/devicediscovery.pri 2014-01-13 13:23:37.000000000 +0100
    (at)(at) -9,4 +9,8 (at)(at)
    } else {
    SOURCES += $$PWD/qdevicediscovery_static.cpp
    }
    +} else:unix {

    • HEADERS += $$PWD/qdevicediscovery_p.h
    • SOURCES += $$PWD/qdevicediscovery_static.cpp
      }
      @

    Next, there's couple of instances where Linux' pthread_getattr_np()
    needs to be replaced by FreeBSD's pthread_attr_get_np():

    @
    --- ./qtdeclarative/src/qml/jsruntime/qv4mm.cpp~ 2013-12-08 18:10:19.000000000 +0100
    +++ ./qtdeclarative/src/qml/jsruntime/qv4mm.cpp 2014-01-13 15:56:20.000000000 +0100
    (at)(at) -67,6 +67,10 (at)(at)
    #include <sys/storage.h> // __tls()
    #endif

    +#if OS(FREEBSD)
    +# include <pthread_np.h>
    +#endif

    QT_BEGIN_NAMESPACE

    using namespace QV4;
    (at)(at) -218,6 +222,16 (at)(at)

    if OS(DARWIN)

     void *st = pthread_get_stackaddr_np(pthread_self());
     m_d->stackTop = static_cast<quintptr *>(st);
    

    +# elif OS(FREEBSD)

    • void* stackBottom = 0;
    • pthread_attr_t attr;
    • pthread_attr_init(&attr);
    • pthread_attr_get_np(pthread_self(), &attr);
    • size_t stackSize = 0;
    • pthread_attr_getstack(&attr, &stackBottom, &stackSize);
    • pthread_attr_destroy(&attr);
    • m_d->stackTop = static_cast<quintptr *>(stackBottom) + stackSize/sizeof(quintptr);

    else

     void* stackBottom = 0;
     pthread_attr_t attr;
    

    @
    and
    @
    --- ./qtdeclarative/src/qml/jsruntime/qv4mm.cpp~ 2013-12-08 18:10:19.000000000 +0100
    +++ ./qtdeclarative/src/qml/jsruntime/qv4mm.cpp 2014-01-13 15:56:20.000000000 +0100
    (at)(at) -67,6 +67,10 (at)(at)
    #include <sys/storage.h> // __tls()
    #endif

    +#if OS(FREEBSD)
    +# include <pthread_np.h>
    +#endif

    QT_BEGIN_NAMESPACE

    using namespace QV4;
    (at)(at) -218,6 +222,16 (at)(at)

    if OS(DARWIN)

     void *st = pthread_get_stackaddr_np(pthread_self());
     m_d->stackTop = static_cast<quintptr *>(st);
    

    +# elif OS(FREEBSD)

    • void* stackBottom = 0;
    • pthread_attr_t attr;
    • pthread_attr_init(&attr);
    • pthread_attr_get_np(pthread_self(), &attr);
    • size_t stackSize = 0;
    • pthread_attr_getstack(&attr, &stackBottom, &stackSize);
    • pthread_attr_destroy(&attr);
    • m_d->stackTop = static_cast<quintptr *>(stackBottom) + stackSize/sizeof(quintptr);

    else

     void* stackBottom = 0;
     pthread_attr_t attr;
    

    @
    Then, there's alloca(), but apparently only ever tested on
    Linux. FreeBSD doesn't have alloca.h but declares it in stdlib.h.
    @
    --- ./qtdeclarative/src/qml/jsruntime/qv4alloca_p.h~ 2013-12-08 18:10:19.000000000 +0100
    +++ ./qtdeclarative/src/qml/jsruntime/qv4alloca_p.h 2014-01-13 16:06:21.000000000 +0100
    (at)(at) -49,6 +49,8 (at)(at)

    ifndef GNUC

    define alloca _alloca

    endif

    +#elif defined(Q_OS_FREEBSD)
    +# include <stdlib.h>
    #else

    include <alloca.h>

    #endif
    @



  • (Have to split the posts to maintain the 6000 char limit.)

    Finally, all the multimedia stuff appears to be written for Linux only.
    There's plenty of #include <linux/something> all over the place. :(
    In order to get it compile at least (it won't make sense at runtime), I
    needed these patches:
    @
    --- ./qtmultimedia/src/gsttools/qgstreamervideoinputdevicecontrol.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/gsttools/qgstreamervideoinputdevicecontrol.cpp 2014-01-13 17:52:25.000000000 +0100
    (at)(at) -44,7 +44,9 (at)(at)
    #include <QtCore/QDir>
    #include <QtCore/QDebug>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -54,7 +56,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif

    QGstreamerVideoInputDeviceControl::QGstreamerVideoInputDeviceControl(QObject *parent)
    :QVideoDeviceSelectorControl(parent), m_selectedDevice(0)
    (at)(at) -110,7 +114,7 (at)(at)
    #ifdef Q_WS_MAEMO_6
    m_names << QLatin1String("primary") << QLatin1String("secondary");
    m_descriptions << tr("Main camera") << tr("Front camera");
    -#else
    +#elif defined(Q_OS_LINUX)
    QDir devDir("/dev");
    devDir.setFilter(QDir::System);

    (at)(at) -151,5 +155,7 (at)(at)
    }
    ::close(fd);
    }
    +#else
    +# warning "QGstreamerVideoInputDeviceControl::update() not implemented on this OS"
    #endif
    }
    --- ./qtmultimedia/src/plugins/gstreamer/mediacapture/qgstreamerv4l2input.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/mediacapture/qgstreamerv4l2input.cpp 2014-01-13 18:01:59.000000000 +0100
    (at)(at) -44,7 +44,9 (at)(at)
    #include <QtCore/qdebug.h>
    #include <QtCore/qfile.h>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -54,7 +56,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif

    QT_BEGIN_NAMESPACE
    static inline uint qHash(const QSize& key) { return uint(key.width()*256+key.height()); }
    (at)(at) -98,6 +102,7 (at)(at)

    void QGstreamerV4L2Input::updateSupportedResolutions(const QByteArray &device)
    {
    +#ifdef Q_OS_LINUX
    m_frameRates.clear();
    m_resolutions.clear();
    m_ratesByResolution.clear();
    (at)(at) -270,6 +275,9 (at)(at)

     //qDebug() << "frame rates:" << m_frameRates;
     //qDebug() << "resolutions:" << m_resolutions;
    

    +#else
    +# warning "QGstreamerV4L2Input::updateSupportedResolutions() not implemented on this OS"
    +#endif
    }

    @


  • Lifetime Qt Champion

    Hi Jörg,

    Did you considered submitting your patches to the Qt project ?



  • @
    --- ./qtmultimedia/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/mediacapture/qgstreamercaptureserviceplugin.cpp 2014-01-13 18:04:29.000000000 +0100
    (at)(at) -51,7 +51,9 (at)(at)
    #include "qgstreamercaptureservice.h"
    #include <private/qgstutils_p.h>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -61,7 +63,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif
    #include <gst/gst.h>

    QMediaService* QGstreamerCaptureServicePlugin::create(const QString &key)
    (at)(at) -131,6 +135,7 (at)(at)

    void QGstreamerCaptureServicePlugin::updateDevices() const
    {
    +#ifdef Q_OS_LINUX
    m_cameraDevices.clear();
    m_cameraDescriptions.clear();

    (at)(at) -174,6 +179,9 (at)(at)
    }
    ::close(fd);
    }
    +#else
    +# warning "QGstreamerCaptureServicePlugin::updateDevices() not implemented on this OS"
    +#endif
    }
    #endif

    --- ./qtmultimedia/src/plugins/gstreamer/camerabin/camerabincontrol.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/camerabin/camerabincontrol.cpp 2014-01-13 18:13:59.000000000 +0100
    (at)(at) -50,7 +50,9 (at)(at)
    #include <QtCore/qfile.h>
    #include <QtCore/qmetaobject.h>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -60,7 +62,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif

    QT_BEGIN_NAMESPACE

    --- ./qtmultimedia/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/camerabin/camerabinserviceplugin.cpp 2014-01-13 18:12:20.000000000 +0100
    (at)(at) -50,7 +50,9 (at)(at)
    #include "camerabinservice.h"
    #include <private/qgstutils_p.h>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -60,7 +62,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif
    #include <gst/gst.h>

    QT_BEGIN_NAMESPACE
    (at)(at) -126,6 +130,7 (at)(at)

    void CameraBinServicePlugin::updateDevices() const
    {
    +#ifdef Q_OS_LINUX
    m_cameraDevices.clear();
    m_cameraDescriptions.clear();

    (at)(at) -167,6 +172,9 (at)(at)
    }
    ::close(fd);
    }
    +#else
    +# warning "CameraBinServicePlugin::updateDevices() not implemented on this OS"
    +#endif
    }

    QT_END_NAMESPACE
    --- ./qtmultimedia/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/audiodecoder/qgstreameraudiodecoderserviceplugin.cpp 2014-01-13 17:56:57.000000000 +0100
    (at)(at) -49,7 +49,9 (at)(at)
    #include <QtCore/QDir>
    #include <QtCore/QDebug>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -59,7 +61,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif
    #include <gst/gst.h>

    // #define QT_SUPPORTEDMIMETYPES_DEBUG
    --- ./qtmultimedia/src/plugins/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp~ 2013-12-08 18:10:15.000000000 +0100
    +++ ./qtmultimedia/src/plugins/gstreamer/mediaplayer/qgstreamerplayerserviceplugin.cpp 2014-01-13 18:09:30.000000000 +0100
    (at)(at) -51,7 +51,9 (at)(at)
    #include "qgstreamerplayerservice.h"
    #include <private/qgstutils_p.h>

    -#include <linux/types.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/types.h>
    +#endif
    #include <sys/time.h>
    #include <sys/ioctl.h>
    #include <sys/poll.h>
    (at)(at) -61,7 +63,9 (at)(at)
    #include <string.h>
    #include <stdlib.h>
    #include <sys/mman.h>
    -#include <linux/videodev2.h>
    +#ifdef Q_OS_LINUX
    +# include <linux/videodev2.h>
    +#endif
    #include <gst/gst.h>

    @

    With all that, I got it to compile. Alas, 1 GB of my datasegment size is too
    small to link it. :-( I'm afraid I have to reboot now ...



  • [quote author="SGaist" date="1389648894"]Hi Jörg,

    Did you considered submitting your patches to the Qt project ?[/quote]

    Will certainly do, but I'd like to get it working for me, first.

    By posting it here, I was in hope to catch the attraction of some
    other FreeBSD developers before ...


  • Lifetime Qt Champion

    A central place to retrieve your patch would be a good idea then. Fellow developers could then jump in to help



  • [quote author="SGaist" date="1389650189"]A central place to retrieve your patch would be a good idea then.[/quote]

    I'll review the patch before, and upload it onto my web server.

    But now it's close to midnight here, time to fall asleep.



  • This post is deleted!


  • This post is deleted!

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.