1

I've written some code (static library) in c++, with (i think so, C compatiblity - got 'extern C' and so on), and then i wanted to use it in my C application.

When im runing my C app, i got error:

undefined symbol: _ZTISt9exception

c++ code was compiled with gcc with : -std=c++0x -lstdc++ flags

then, on obj files i run ar

i suppose that symbol comes direct from c++ library. When im compiling my C app I of course add my C++ lib in my makefile, and compilation finishes with no error.

What might be wrong ?

thx for all help

1

2 Answers 2

1

A static library is not linked, it is just a collection of object files in an archive. All files names like libxxx.a are static libraries, while files named like libyyy.so are dynamic libraries.

This means that the the external symbols in your library are never resolved until you link with it to make an executable. Then you need all the library files needed by your library as well.

Sign up to request clarification or add additional context in comments.

Comments

1

You'll need to link the final executable with the C++ runtime library (-lstdc++); it has no effect when compiling the C++ objects, only linking the executable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.