Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

what to configure for running threads in eclipse

$
0
0

i know it is a well known problem.

i have a simple thread c++ code:

#include <string>
#include <iostream>
#include <thread>

using namespace std;

// The function we want to execute on the new thread.
void task1(string msg)
{
    cout << "task1 says: "<< msg;
}

int main()
{
    // Constructs the new thread and runs it. Does not block execution.
    thread t1(task1, "Hello");

    // Do other things...

    // Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution.
    t1.join();
}

All i want i to run this code.. i think i use the gcc c++ compiler with :

-O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -l pthread

and i think i use mingw c++ Linker with:

-pthread -Xlinker -pthread

As i am getting more and more upset i thought i should ask you, before i kill my pc.

Maybe you have some advise ... This guy also has a nice tutorial, but it didn't help https://www.quora.com/Why-could-the-thread-type-not-be-resolved-in-Eclipse-C++-even-when-the-compiler-doesnt-give-any-error-on-including-thread

By the way, this happens when i Press build:

**** Build of configuration Debug for project f ****

**** Internal Builder is used for build               ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -std=c++11 -std=c++0x -osrc\f.o ..\src\f.cpp
..\src\f.cpp: In function 'int main()':
..\src\f.cpp:16:5: error: 'thread' was not declared in this scope
..\src\f.cpp:16:12: error: expected ';' before 't1'
..\src\f.cpp:21:5: error: 't1' was not declared in this scope
Build error occurred, build is stopped
Time consumed: 615  ms.  

My Eclipse doesnt have : enter image description here

https://www.fayewilliams.com/2015/04/14/c11-threads-dont-work-in-eclipse-luna/


Viewing all articles
Browse latest Browse all 21994

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>