title: How to resolve linker error "cannot find -lgcc_s"
body: <p>I have 3 tiny files which I use to make a static library and an app:</p>
  
  <p><strong><em>test.h</em></strong></p>
  
  <pre><code>#ifndef TEST_H
  #define TEST_H
  
  class Test
  {
      public:
          Test();
  };
  
  extern Test* gpTest;
  
  #endif
  </code></pre>
  
  <p><strong><em>test.cpp</em></strong></p>
  
  <pre><code>#include "test.h"
  
  Test::Test()
  {
      gpTest = this;
  }   
  
  Test test;
  </code></pre>
  
  <p><strong><em>main.cpp</em></strong></p>
  
  <pre><code>#include "test.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  Test* gpTest = NULL;
  
  int main()
  {
      return 0;
  }
  </code></pre>
  
  <p><strong>BUILD</strong></p>
  
  <pre><code>g++ -c test.cpp -o test.o
  ar cr test.a test.o
  g++ -c main.cpp -o main.o
  g++ main.o -o app -Wl,--whole-archive -L/home/dumindara/intest/test.a -Wl,-no--whole-archive
  </code></pre>
  
  <p><strong>ERROR (linking step)</strong></p>
  
  <pre><code>/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lgcc_s
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I tried everything: using -static-libgcc and linking to static libstdc++. Can't get this to work. It is all due to --whole-archive flag. But I can't do without it.</p>