From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 42CE93858D39 for ; Thu, 21 Oct 2021 12:34:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 42CE93858D39 Received: by mail-wr1-x429.google.com with SMTP id d3so825812wrh.8 for ; Thu, 21 Oct 2021 05:34:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZqbwhIXzRa3G+06c7TuMHNQn4ayJfZDoWM6XGG5iC8k=; b=YQrL2qNG46SVk4NZoEkiMISFkCGTn4Cjz68iBz3AgD3S8iFd18cx1LoBiMBt0IeO9Z jzIfCwctsUVeU6PssSf0oHQrRtpQnjRwMMYDYijINenqwAV+MilmVB6FGaoxeeD7ve+p iSowbSzzAsBLe16QBMeK1vlwRZw7ILMFfspnXb4rbCBOdsyS/HjnrWzWfRV+blO2GP6m Ccl4lJKObPlv9GnPM6n6tp4Qiq8mXGEt4JiWDUPGOpUPED7TRHcnej2g8WIgAvDnD2ZG LVgFsg4FHq0cKbiRUbhVv1PfY8JA9H7dFwkdQHtdxLsjp+1YyqYNZr+nGJeMbbKuyZV2 jkUQ== X-Gm-Message-State: AOAM531U+llV4OXNUhE5D3OoNDriP0htsZS8Xv5iITYeDbj5cuZZvMbX eqv1KFz0b9qW75rdJuG454622QM+66WUVD42Njc= X-Google-Smtp-Source: ABdhPJzNxC/hbxiHcZ09o9XA+0wzjrohMqiOf7wSO9OwgTRdnWHYTy0Pyq0c8NdRXerd7hPg5jXkQmkWBNd+liUf6n4= X-Received: by 2002:a5d:4481:: with SMTP id j1mr7374806wrq.6.1634819679314; Thu, 21 Oct 2021 05:34:39 -0700 (PDT) MIME-Version: 1.0 References: <20f6fd91.5593e.17c6d6050ed.Coremail.guiyonglin@huaqin.com> <0e6a4bba-872f-92e5-af61-e5cc94a2b547@126.com> <241991aa.65e41.17c9e31312b.Coremail.guiyonglin@huaqin.com> <3515425a.16174.17ca0ec071d.Coremail.guiyonglin@huaqin.com> <9c61a693cd8fc6544787472482c31984c4a3114d.camel@mengyan1223.wang> In-Reply-To: <9c61a693cd8fc6544787472482c31984c4a3114d.camel@mengyan1223.wang> From: Jonathan Wakely Date: Thu, 21 Oct 2021 13:34:28 +0100 Message-ID: Subject: Re: Re: GCC link problem help! To: Xi Ruoyao Cc: =?UTF-8?B?5qGC5rC45p6X?= , LIU Hao , Tom Kacvinsky , gcc-help , =?UTF-8?B?5p+z6IyC5piV?= , =?UTF-8?B?5p2O6Zev6Zev?= , =?UTF-8?B?5rGk5rGd?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2021 12:34:41 -0000 On Thu, 21 Oct 2021 at 13:06, Xi Ruoyao via Gcc-help wrote: > > On Thu, 2021-10-21 at 11:36 +0800, =E6=A1=82=E6=B0=B8=E6=9E=97 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.