How to make CDT/Eclipse work with C++11 threads?

后端 未结 3 2428
予麋鹿
予麋鹿 2021-02-20 01:15

I tried to test an example of C++11 threads in Eclipse. But I got this message when running the program:

terminate called after throwing an instance of \'

3条回答
  •  礼貌的吻别
    2021-02-20 01:49

    1. Go to Project > Properties > C/C++ General > Preprocessor include paths, etc > Providers > CDT GCC Builtin Compiler Settings and append -std=c++11 to the compiler specs.

      You can also do this for all projects going to Window > Preferences > C/C++ > Build > Settings > Discovery and append -std=c++11 to the CDT GCC Builtin Compiler Settings specs.

       ${COMMAND} ${FLAGS} -E -P -v -dD -std=c++11 "${INPUTS}"
      
    2. Project Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Miscellaneous > Other flags, add -pthread -std=c++11 -Wl,--no-as-needed:

       -c -fmessage-length=0 -pthread -std=c++11 -Wl,--no-as-needed
      
    3. Project Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Linker > Miscellaneous > Linker flags, add -pthread -std=c++11 -Wl,--no-as-needed

       -pthread -std=c++11 -Wl,--no-as-needed
      

提交回复
热议问题