From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B8CBB385842E; Mon, 23 Oct 2023 14:28:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8CBB385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698071316; bh=3q6UXGISdRJPF2Zgoj3xp2yiOpYOZeMnft96yCrbZMQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WwdWGFrkPXBM8+3u8+bdknbzUezPv4OIYxzl4oo+ML4bRLy975ZpLvPeAT5vpr6Uy VLWA57EDkAGXYofLZFL112Pv4AkwDtQnqs+T4atPwbUYkXjXmI2qAHwFAoQ/imVD0p pHqbIGZOlhK0hqdOaRNPuwpSYlKHwL4Lyr5a4fUU= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/111936] std::stacktrace cannot be used in a shared library Date: Mon, 23 Oct 2023 14:28:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111936 --- Comment #2 from Jonathan Wakely --- (In reply to vincenzo Innocente from comment #0) > it silently compiles with > [innocent@patatrack01 ctest]$ c++ -O3 -Wall -pthread -fPIC -shared > -std=3Dc++23 -lstdc++exp getStacktrace.cc >=20 > but the symbols are undefined This is simply because you need to list libraries after the files that depe= nd on them: https://c-faq.com/lib/libsearch.html When the linker sees -lstdc++exp there are no undefined references to any of the symbols it provides, so the linker ignores it. Then it sees getStacktra= ce.o which has undefined refs but it's too late, the archive has already been processed. The library should be compiled as PIC though, which is a separate issue.=