1

I am using the following code snippet and compiling using the static linking.

#include<iostream>
#include <thread>

void hello()
{
    std::cout<<"Hello Concurrent World\n";
}

int main()
{
    std::thread t(hello);
    t.join();
}

Here is the compilation command which I am using -

g++ -std=c++11 -o main -pthread  -static -static-libgcc -static-libstdc++ temp.cpp

but when I try to execute the generated binary, I am getting segmentation fault.

But I dont see any error If I compile using the following command -

g++ -std=c++11 -o main2 -pthread  temp.cpp

Can someone please help what might be causing the segmentation fault while compiling using the static linking.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
Ankur Goel
  • 311
  • 1
  • 11

0 Answers0