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. C++11 and Qt 5?

C++11 and Qt 5?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    CroCo
    wrote on last edited by
    #1

    I'm trying to use (#include <thread> ) in c++11 with Qt 5 but with no luck. I'm using Mac and this is what I did
    My qmake project
    @QT += core
    QT -= gui

    CONFIG += c++11
    CONFIG -= app_bundle
    TARGET = test
    TEMPLATE = app
    SOURCES += main.cpp@

    My main.cpp

    @#include <thread>
    #include <iostream>

    void foo()
    {
    std::cout << "In foo() \n";
    }

    void bar(int x)
    {
    std::cout << "In bar() \n";
    }

    int main()
    {
    std::thread first(foo);
    std::thread second(bar,0);

    std::cout << "main, foo and bar now execute concurrently ...\n";
    
    first.join();
    second.join();
    
    std::cout << "foo and bar completed.\n";
    return 0;
    

    }
    @

    These errors that I'm getting

    @main.cpp:1:18: error: thread: No such file or directory
    main.cpp:10: warning: unused parameter ‘x’
    main.cpp: In function ‘int main()’:
    main.cpp:17: error: ‘thread’ is not a member of ‘std’
    main.cpp:17: error: expected ;' before ‘first’ main.cpp:18: error: ‘thread’ is not a member of ‘std’ main.cpp:18: error: expected ;' before ‘second’
    main.cpp:22: error: ‘first’ was not declared in this scope
    main.cpp:23: error: ‘second’ was not declared in this scope
    make: *** [main.o] Error 1@

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You need to provide more information: what version of OS X ? What version of Xcode ? etc.

      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
      • C Offline
        C Offline
        CroCo
        wrote on last edited by
        #3

        @SGaist,
        Mac OS X Lion 10.7.5
        Xcode Version 4.3.3
        Qt 5.0.1 (64 bit)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          "This":http://stackoverflow.com/questions/14115314/how-to-compile-c11-with-clang-3-2-on-osx-lion might help

          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

          • Login

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