c++ - How to resolve linker error "cannot find -lgcc_s" -


i have 3 tiny files use make static library , app:

test.h

#ifndef test_h #define test_h  class test {     public:         test(); };  extern test* gptest;  #endif 

test.cpp

#include "test.h"  test::test() {     gptest = this; }     test test; 

main.cpp

#include "test.h" #include <iostream>  using namespace std;  test* gptest = null;  int main() {     return 0; } 

build

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 

error (linking step)

/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 

i tried everything: using -static-libgcc , linking static libstdc++. can't work. due --whole-archive flag. can't without it.

i think -- problem here:

-wl,-no--whole-archive 

try with

-wl,-no-whole-archive 

edit

about not seeing test symbol in app nm app: think don't need -l since give full path , name of test.a - either

-wl,--whole-archive -l/home/dumindara/intest/ -ltest -wl,-no-whole-archive 

or

-wl,--whole-archive /home/dumindara/intest/test.a -wl,-no-whole-archive 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -