[Solved] Embedded Linux data directory

  • Hi,
    i've been trying to run Qt app on embedded device but i am getting following error:

    Cannot create Qt for Embedded Linux data directory: /tmp/qtembedded-0

    This message is right because my root dir is read only partition, read write partition is mounted on /APPL. Is there any way to tell Qt to use ie /APPL/tmp to create data directory?
    Thanks for you answers!

  • Hmmm, good question and I'm not sure. A possible work around is to make /tmp writable. You could do this by making it a tmpfs filesystem type. ie add something like this to your /etc/fstab:

    none /tmp/ tmpfs size=1M 0 0

    which would create a tmpfs ramdisk with maximum size of 1MB.

  • OK I've done some digging and here's what I've found. The QWSServer object tries to create and listen on a local socket which by default is /tmp/qtembedded-0. This is done in qwindowsystem_qws.cpp:

    void QWSServerPrivate::initServer(int flags)
    qwsServer = q;
    qwsServerPrivate = this;
    disablePainting = false;
    ssocket = new QWSServerSocket(qws_qtePipeFilename(), q);

    where the function qws_qtePipeFilename() is defined in qapplication_qws.cpp and in turn calls qws_dataDir() which is in the same file. This in turn calls:

    QString qws_dataDir()
    static QString result;
    if (!result.isEmpty())
    return result;
    result = QT_VFB_DATADIR(qws_display_id);

    where QT_VFB_DATADIR is a macro in qvfbhdr.h declared as:

    #define QT_VFB_DATADIR(DISPLAY) QString("%1/qtembedded-%2-%3")

    and finally we see trace down that we need QT_QWS_TEMP_DIR which is declared as:

    #ifndef QT_QWS_TEMP_DIR
    #define QT_QWS_TEMP_DIR "/tmp"

    So now we see that to locate the socket to a different location we somehow need to define QT_QWS_TEMP_DIR to a path of your choice that is writeable by the user your application will be running as.

    I think you should be able to do this by defining QT_QWS_TEMP_DIR in the qplatformdefs.h of your custom mkspec. Then rebuild Qt Embedded for your target device and deploy and test.

    Good luck!

  • Hello,
    thanks a lot for your answer and digging:) I'v decided to take simple solution and made /tmp writable. I was hoping that there will be some kind of easy solution like setting some enviroment variable not rebuilding Qt Embedded:)

  • We made the /tmp directory as "tmpfs" as ZapB mentioned above.

  • No problem. Either solution will work. It depends on your device configuration and other constraints as to what is the easiest. I've used the tmpfs approach too when we were booting a very minimal system using just an initramfs to launch only our application.

Log in to reply

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