I want to make a static library called libXYZ.a using some existing static libraries: libX.a, libY.a, libZ.a and some object files. The command line I used to build the static library libXYZ.a is:
ld -o libXYZ.a one.o two.o -L./ -L/cygdrive/c/cygwin/lib/gcc/i686-pc-cygwin/4.8.2 -lX -lY -lZ -lstdc++
I'm using Cygwin GCC (g++) to compile one.cpp and two.cpp to get one.o and two.o before the ld command like the following:
g++ -o one.o one.cpp -c
g++ -o one.o two.cpp -c
libX.a, libY.a, libZ.a are all located in the current directory (that's why -L./). And I added the C++ standard library linker flag -lstdc++ in the ld line. But I got the following error when I make it:
one.o: one.cpp:(.text+0x32): undefined reference to `_Unwind_Resume'
ld: one.o: bad reloc address 0xd in section `.text$_ZN10ConfigC1Ev[__ZN10ConfigC1Ev]'
Makefile:22: recipe for target 'libXYZ.a' failed
So my question is: Is the ld command the right command to build the static lib from other static libs and .o files? What caused the error? I searched the forum and found that it is possible caused by some incompatible compiler. But I built all my source code using the same GCC compiler.
UPDATE:
I tried again using the following command:
ld -o libXYZ.a one.o two.o -L./ -lX -lY -lZ
But I'm still getting the following errors:
one.o:one.cpp:(.text+0x32): undefined reference to `_Unwind_Resume'
one.o:one.cpp:(.text+0x12a): undefined reference to `_Unwind_Resume'
...
./libX.a(wrapper.o):wrapper.cpp:(.text+0x7ba): undefined reference to `__chkstk_ms'
./libX.a(wrapper.o):wrapper.cpp:(.text+0x7ba): undefined reference to `_Unwind_Resume'
...
And I omitted numerous similar errors like the above _Unwind_Resume errors. Any ideas on what caused those errors?