Friday 31 July 2015

Ubuntu Eclipse CDT with C11 & pthread

1. Create a C++ project

2. Enable C++11

2.1 Once created, right-click the project and go to "Properties"

2.2 C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler -> Miscellaneous -> Other Flags


3. Update content assist (to avoid error: Type "thread" cannot be resolved)

3.1  Go to Project -> Properties -> C/C++ General -> Preprocessor include paths, etc -> Providers -> CDT GCC Builtin Compiler Settings

3.2 Disable the Share flag and append -std=c++11 to the compiler specs.

4. Test program

#include
#include

using namespace std;

void threadFunc()
{
    cout << "Welcome to Multithreading" << endl;

}

int main(int argc, char **argv) {
    //pass a function to thread
    thread funcTest1(threadFunc);

    funcTest1.join();
}


5. for Window + MinGW
http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds

No comments:

Post a Comment