Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. std::thread run time error "Enable multithreading to use std::thread: Operation not permitted"

std::thread run time error "Enable multithreading to use std::thread: Operation not permitted"

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 5.6k 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.
  • dhan2308D Offline
    dhan2308D Offline
    dhan2308
    wrote on last edited by
    #1

    I am trying to port a program that was running without any problem when the environment set up was
    Ubuntu 12.0
    QTCreator Version - 2.4.1
    QT - 4.8.0
    gcc - 4.6.3 to a new environment

    Ubuntu 14.04
    QTCreator Version - 3.0.1
    QT - 5.2.1
    gcc - 4.8

    Unfortunately I end up seeing a runtime error "terminate called after throwing an instance of 'std::system_error' what(): Enable multithreading to use std::thread:Operation not permitted"

    As per my understanding this seems to be an issue with compiler compatibility. Either I miss some options during compilations or a bug from compiler.

    How to get his fixed? Any help is greatly appreciated.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi, and welcome to the Qt forum!
      That's a bug in the Ubuntu gcc package, see here. As a workaround it's suggested to add the following compiler flags: -Wl,--no-as-needed

      dhan2308D 1 Reply Last reply
      2
      • ? A Former User

        Hi, and welcome to the Qt forum!
        That's a bug in the Ubuntu gcc package, see here. As a workaround it's suggested to add the following compiler flags: -Wl,--no-as-needed

        dhan2308D Offline
        dhan2308D Offline
        dhan2308
        wrote on last edited by
        #3

        @Wieland Thank you very much for the reply. I have tried that and still see the same issue. Please find my compile output. Any issue with the compiler options?

        ++ -c -pipe -std=c++11 -pthread -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/i386-linux-gnu/qt5/mkspecs/linux-g++ -I../SimulatorSiteControl -I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -I. -o map.o ../SimulatorSiteControl/Map/map.cpp
        g++ -Wl,-O1 -o SimulatorSimulatorSiteControl main.o simulator.o map.o cbmapnotification.o notifymapactivestate.o -lQt5Gui -L/usr/lib/i386-linux-gnu -lQt5Core -lGL -lpthread

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by A Former User
          #4

          Are you using qmake for this? How did you add the suggested compiler options?

          kshegunovK 1 Reply Last reply
          2
          • ? A Former User

            Are you using qmake for this? How did you add the suggested compiler options?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by kshegunov
            #5

            @Wieland
            It can't be qmake, as in my experience qmake generates the make compile lines with -fPIC and doesn't rely on the "position independent executable" option in g++. Also switching from one optimization level to the other between compiler and linker is odd ...

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            1
            • dhan2308D Offline
              dhan2308D Offline
              dhan2308
              wrote on last edited by
              #6

              @Wieland, @kshegunov ,

              Its qmake as per my understanding. I tried adding QMAKE_CXXFLAGS += -Wl,--no-as-needed and CONFIG += -Wl,--no-as-needed in .pro file. Both options generate the same output.
              Please find compiler output
              11:22:41: Running steps for project SimulatorSimulatorSiteControl...
              11:22:41: Starting: "/usr/lib/i386-linux-gnu/qt5/bin/qmake" /home/dhanesh/Simulator/SimulatorSiteControl/SimulatorSimulatorSiteControl.pro -r -spec linux-g++ CONFIG+=declarative_debug CONFIG+=qml_debug
              11:22:41: The process "/usr/lib/i386-linux-gnu/qt5/bin/qmake" exited normally.
              11:22:41: Starting: "/usr/bin/make"

              In generated makefile I see LFLAGS = -Wl,-O1

              I still miss something and just not sure what it is.

              kshegunovK 1 Reply Last reply
              0
              • dhan2308D dhan2308

                @Wieland, @kshegunov ,

                Its qmake as per my understanding. I tried adding QMAKE_CXXFLAGS += -Wl,--no-as-needed and CONFIG += -Wl,--no-as-needed in .pro file. Both options generate the same output.
                Please find compiler output
                11:22:41: Running steps for project SimulatorSimulatorSiteControl...
                11:22:41: Starting: "/usr/lib/i386-linux-gnu/qt5/bin/qmake" /home/dhanesh/Simulator/SimulatorSiteControl/SimulatorSimulatorSiteControl.pro -r -spec linux-g++ CONFIG+=declarative_debug CONFIG+=qml_debug
                11:22:41: The process "/usr/lib/i386-linux-gnu/qt5/bin/qmake" exited normally.
                11:22:41: Starting: "/usr/bin/make"

                In generated makefile I see LFLAGS = -Wl,-O1

                I still miss something and just not sure what it is.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @dhan2308
                Do you mind sharing the project file you run through qmake?

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • dhan2308D Offline
                  dhan2308D Offline
                  dhan2308
                  wrote on last edited by
                  #8

                  QMAKE_CXXFLAGS += -std=c++11 -pthread
                  QMAKE_CXXFLAGS += -Wl,--no-as-needed
                  TEMPLATE = app
                  CONFIG += -console
                  CONFIG += -qt

                  SOURCES += main.cpp
                  simulator.cpp
                  Map/map.cpp
                  Map/Interface/cbmapnotification.cpp
                  Map/notifymapactivestate.cpp

                  HEADERS +=
                  Map/map.h
                  Common/Simlistener.h
                  Map/Interface/cbmapnotification.h
                  simulator.h
                  Map/notifymapactivestate.h
                  Common/SimEventQueueHandler.h

                  kshegunovK 1 Reply Last reply
                  0
                  • dhan2308D dhan2308

                    QMAKE_CXXFLAGS += -std=c++11 -pthread
                    QMAKE_CXXFLAGS += -Wl,--no-as-needed
                    TEMPLATE = app
                    CONFIG += -console
                    CONFIG += -qt

                    SOURCES += main.cpp
                    simulator.cpp
                    Map/map.cpp
                    Map/Interface/cbmapnotification.cpp
                    Map/notifymapactivestate.cpp

                    HEADERS +=
                    Map/map.h
                    Common/Simlistener.h
                    Map/Interface/cbmapnotification.h
                    simulator.h
                    Map/notifymapactivestate.h
                    Common/SimEventQueueHandler.h

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by kshegunov
                    #9

                    @dhan2308
                    Hello,

                    Why those lines?

                    CONFIG += -console
                    CONFIG += -qt
                    

                    Additionally, c++11 can be passed as config, and there's in general no need to mess with the compiler/linker flags directly. Is your application a Qt GUI or do you have a console application; do you use Qt in it, or you just use qmake and Creator as build environment?

                    If you don't use Qt at all, you can try something along the lines (for a console app):

                    QT -= core gui  #< No Qt libraries
                    
                    TEMPLATE = app
                    
                    CONFIG += c++11 console #< Console application with C++11 enabled (if the compiler supports it)
                    CONFIG -= app_bundle
                    
                    LIBS += -lpthread   #< Although, I think this is not necessary. I think qmake links that by default
                    
                    SOURCES += ...
                    HEADERS += ...
                    

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0
                    • dhan2308D Offline
                      dhan2308D Offline
                      dhan2308
                      wrote on last edited by
                      #10

                      Thank You All. Finally I got it working. The way I passed compiler option was wrong. Once again thank you very much for the support and guidance

                      1 Reply Last reply
                      0

                      • Login

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