Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Raspberry Pi thread - pure virtual function called
QtWS25 Last Chance

Raspberry Pi thread - pure virtual function called

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
threadraspberry pi 2g++bug
5 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeterPan32
    wrote on 19 Jun 2016, 04:52 last edited by
    #1

    Hi,
    I'm currently developing a big project under the Raspberry Pi 2 (with Qt Creator).
    Yesterday I was dealing with threads. I got an annoying runtime error.
    So I wrote a little example that shows my problem:

    #include <iostream>
    #include <thread>
    using namespace std;
    
    void hello_function()
    {
        cout << "function hello"<<endl;
    }
    
    int main()
    {
        cout << "1" << endl;
        thread t(hello_function);
        cout << "2" << endl;
        t.join();
        return 0;
    }
    

    output:

    1
    2
    pure virtual method called
    terminate called without an active exception
    

    The error is caused by the thread. After some research I found out that this is a bug in gcc compiler:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62100
    You'll also find out, that there is recommended to use "-mcpu=cortex-a8" as solution.
    Can anyone explain me where to put this command? Possible to put this in qt's project file?

    At last, some additional information:
    Qt project file:

    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt
    
    CONFIG   += c++14
    CONFIG += thread
    
    SOURCES += main.cpp
    
    include(deployment.pri)
    qtcAddDeployment()
    

    Some versions:
    Qt Creator 3.2.1 based on Qt 5.3.2 (under Raspberry Pi 2)
    g++ (Raspbian 4.9.2-10) 4.9.2

    /etc/issue:
    Raspbian GNU/Linux 8 \n \l

    /proc/version:
    Linux version 4.1.19-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #858 SMP Tue Mar 15 15:56:00 GMT 2016

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 19 Jun 2016, 20:46 last edited by
      #2

      Hi,

      You can edit the qmake.conf file in the mkspecs/device/linux-rasp-pi2-g++ folder.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PeterPan32
        wrote on 20 Jun 2016, 13:33 last edited by
        #3

        Thank you for your help. But that didn't change anything.
        I had a look at the makefile and I'm a bit confused:

        CC            = /usr/bin/gcc
        CXX           = /usr/bin/g++
        DEFINES       = 
        CFLAGS        = -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard -g -D_REENTRANT -Wall -W -fPIC $(DEFINES)
        CXXFLAGS      = -pipe -marm -mfpu=vfp -mtune=arm1176jzf-s -march=armv6zk -mabi=aapcs-linux -mfloat-abi=hard -g -D_REENTRANT -std=c++1y -Wall -W -fPIC $(DEFINES)
        INCPATH       = -I../threadtest -I. -I/usr/local/qt5/mkspecs/devices/linux-rasp-pi-g++
        QMAKE         = /usr/local/qt5/bin/qmake
        DEL_FILE      = rm -f
        CHK_DIR_EXISTS= test -d
        MKDIR         = mkdir -p
        COPY          = cp -f
        COPY_FILE     = cp -f
        COPY_DIR      = cp -f -R
        INSTALL_FILE  = install -m 644 -p
        INSTALL_PROGRAM = install -m 755 -p
        INSTALL_DIR   = cp -f -R
        DEL_FILE      = rm -f
        SYMLINK       = ln -f -s
        DEL_DIR       = rmdir
        MOVE          = mv -f
        TAR           = tar -cf
        COMPRESS      = gzip -9f
        DISTNAME      = threadtest1.0.0
        DISTDIR = /home/pi/build-threadtest-Qt_5_5_1_qt5-Debug/.tmp/threadtest1.0.0
        LINK          = /usr/bin/g++
        LFLAGS        = -Wl,-rpath-link,/opt/vc/lib -Wl,-rpath-link,/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/lib/arm-linux-gnueabihf -mfloat-abi=hard
        LIBS          = $(SUBLIBS) -lpthread 
        AR            = /usr/bin/ar cqs
        RANLIB        = 
        SED           = sed
        STRIP         = /usr/bin/strip
        ...
        

        Should the compiler flag -march=armv6zk not be something like armv7 ?
        I also tried to add -mcpu=cortex-a8 manually, but the compiler reacts with a warning:
        warning: switch -mcpu=cortex-a8 conflicts with -march=armv6zk switch

        I think I have a bad setting. Obviously the makefile does not fit to the qmake.conf:

        # qmake configuration for the Raspberry Pi 2
        
        include(../common/linux_device_pre.conf)
        
        QMAKE_LFLAGS           += -Wl,-rpath-link,$$[QT_SYSROOT]/opt/vc/lib
        
        QMAKE_LIBDIR_OPENGL_ES2 = $$[QT_SYSROOT]/opt/vc/lib
        QMAKE_LIBDIR_EGL        = $$QMAKE_LIBDIR_OPENGL_ES2
        
        QMAKE_INCDIR_EGL        = $$[QT_SYSROOT]/opt/vc/include \
                                  $$[QT_SYSROOT]/opt/vc/include/interface/vcos/pthreads \
                                  $$[QT_SYSROOT]/opt/vc/include/interface/vmcs_host/linux
        QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
        
        QMAKE_LIBS_EGL          = -lEGL -lGLESv2
        QMAKE_CFLAGS += -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux
        QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS
        
        DISTRO_OPTS += hard-float
        
        # Preferred eglfs backend
        EGLFS_DEVICE_INTEGRATION = eglfs_brcm
        
        include(../common/linux_arm_device_post.conf)
        
        load(qt_config)
        

        Regards

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 20 Jun 2016, 20:10 last edited by
          #4

          Is it me or the pasted qmake.conf doesn't contain cortex-a8 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          O 1 Reply Last reply 21 Jun 2016, 09:32
          0
          • S SGaist
            20 Jun 2016, 20:10

            Is it me or the pasted qmake.conf doesn't contain cortex-a8 ?

            O Offline
            O Offline
            onek24
            wrote on 21 Jun 2016, 09:32 last edited by onek24
            #5

            @SGaist said:

            mkspecs/device/linux-rasp-pi2-g++

            Shouldn't it maybe be mkspecs/device/linux-rasp-pi-g++ (without the 2)?
            In his makefile there is this line:

            INCPATH       = -I../threadtest -I. -I/usr/local/qt5/mkspecs/devices/linux-rasp-pi-g++
            
            1 Reply Last reply
            0

            3/5

            20 Jun 2016, 13:33

            • Login

            • Login or register to search.
            3 out of 5
            • First post
              3/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved