views:

292

answers:

2

Hi, all. I've read this article before I asked this question:Linking libstdc++ statically

I just can not understand his explaination of why linking statically simplye not ganna work. Can anybody here help me out? (since orignial blog feedback is closed, I can't help but asking here)

A: 

The stdc++ you statically link with and the stdc++ that the dynamically-linked libraries use when your program is run may be incompatible. If you dynamically link, then the stdc++ used in both cases will be the one and same.

Linking to libstdc++.a directly is statically linking to it. You just have to be aware of the caveats due to version incompatibility mentioned in the article.

dendryte
+1  A: 

It doesn't say that linking libstdc++ statically will not work.

It says that if you want to link libstdc++ statically, you need to link all of your C++ code statically as well.

R Samuel Klatchko
I mean this part: "Note that this problem cannot, in general, be solved by linking statically. First of all, code compiled against different ABIs is simply not binary compatible. It doesn't matter if you manage to link binary incompatible code together, because it will never work properly. Secondly, the language runtime support typically rely on some data being shared, e.g. to access some kind of lock or global data structure (similar to how C programs need a shared errno)."
solotim