Why does linking with pthread cause a segmentation fault?

前端 未结 4 525
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 01:15

I have a stripped down simple program with a static variable (\'abc.cpp\'):

#include 

int main(int, char**)
{
  static const std::string a(\         


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 01:22

    $ man gcc
    

    is your friend. There is more to using the threading library than just including the library in the linking step: the files should be compiled using the "-pthread" switch too.

提交回复
热议问题