From owner-freebsd-hackers@freebsd.org Sat Nov 3 15:47:50 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 262E010DB731 for ; Sat, 3 Nov 2018 15:47:50 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B908986EB1 for ; Sat, 3 Nov 2018 15:47:49 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::d46f:9b92:e1e6:6d2f] (unknown [IPv6:2001:470:7a58:0:d46f:9b92:e1e6:6d2f]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 0A8F01524A; Sat, 3 Nov 2018 16:47:41 +0100 (CET) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_AB3D4540-AD0E-41C2-927C-E4E172DB92E3"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: help with dl module and clang Date: Sat, 3 Nov 2018 16:47:37 +0100 In-Reply-To: <4B8101F4-9A89-4486-8DF3-93DC799EF6D4@cs.huji.ac.il> Cc: freebsd-hackers@FreeBSD.org To: Daniel Braniss References: <4B8101F4-9A89-4486-8DF3-93DC799EF6D4@cs.huji.ac.il> X-Mailer: Apple Mail (2.3445.9.1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2018 15:47:50 -0000 --Apple-Mail=_AB3D4540-AD0E-41C2-927C-E4E172DB92E3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 3 Nov 2018, at 15:51, Daniel Braniss wrote: >=20 > I have a program that loads some modules via dlopen(), these modules = call some routines > which are in the main program, this works when using gcc, but with cc = it does not. >=20 > when compiling the main program I use -export-dynamic, and the = modules link fine when compiled with > gcc, but when compiling with clang/cc i get dlerror: ...Undefined = symbol =E2=80=A6 > BTW, when linking the main program with cc I get > /usr/bin/ld: warning: cannot find entry symbol xport-dynamic; = defaulting to 0000000000402140 Instead of using -export-dynamic (which is a linker flag) as a flag to cc, try using -Wl,-export-dynamic instead. Now, the linker interprets this as the -e flag, which is something totally different. I think this will also help with the exporting of the symbols of your main program. -Dimitry --Apple-Mail=_AB3D4540-AD0E-41C2-927C-E4E172DB92E3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCW93DGQAKCRCwXqMKLiCW o9O0AJ9tC96/mSUaHKoTaHuqd4Ar0Ss+NgCg6zU4kLcbNNKUgIbJm8zNw3dqlZQ= =nIL3 -----END PGP SIGNATURE----- --Apple-Mail=_AB3D4540-AD0E-41C2-927C-E4E172DB92E3--