GCC link problem help!

Jonathan Wakely jwakely.gcc@gmail.com
Thu Oct 21 12:34:28 GMT 2021


On Thu, 21 Oct 2021 at 13:06, Xi Ruoyao via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> On Thu, 2021-10-21 at 11:36 +0800, 桂永林 wrote:
> > If there is some special parameter we need check, when we link the c++
> > lib to C program with C linker?
>
> -lstdc++ is enough as you've already disabled exception and rtti.  If
> exception or rtti is used, -lsupc++ is also needed.

No, everything in libsupc++ is also included in libstdc++ so you do
not need both.

libsupc++ is for when you *only* want the language support, not the
library utilities like iostreams, std::string, std::list etc.

But libsupc++ is not just for exceptions and RTTI, it's also new and
delete, and initialization of local static variables. So if you
haven't used -lstdc++ then you need -lsupc++ to be able to use those
basic features. If you have used -lstdc++, you don't need -lsupc++ for
anything.

If you simply use g++ to link instead of gcc then you get -lstdc++
automatically. That's the recommended way to link a program that has
C++ components.

Since you've only told us that "the program have runtime logic problem
sometimes" nobody can really help you. That's too vague for us to know
what the problem is.


More information about the Gcc-help mailing list