Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Jun 2004 18:43:26 +0200
From:      Michael Nottebrock <michaelnottebrock@gmx.net>
To:        freebsd-current@FreeBSD.org
Cc:        Frerich Raabe <raabe@kde.org>
Subject:   Re: dlclose problem
Message-ID:  <200406191843.26708.michaelnottebrock@gmx.net>
In-Reply-To: <200406191820.26499.michaelnottebrock@gmx.net>
References:  <200406191820.26499.michaelnottebrock@gmx.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--Boundary-03=_u0G1A7ly03yeISI
Content-Type: multipart/mixed;
  boundary="Boundary-01=_u0G1A6Log3OeQZZ"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_u0G1A6Log3OeQZZ
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Saturday 19 June 2004 18:20, Michael Nottebrock wrote:
> Attached is a small testcase made by Frerich Raabe=20

Since the mailinglist strips tarballs, here is the case uncompressed.

=2D-=20
   ,_,   | Michael Nottebrock               | lofi@freebsd.org
 (/^ ^\) | FreeBSD - The Power to Serve     | http://www.freebsd.org
   \u/   | K Desktop Environment on FreeBSD | http://freebsd.kde.org

--Boundary-01=_u0G1A6Log3OeQZZ
Content-Type: text/plain;
  charset="iso-8859-1";
  name="Makefile"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="Makefile"

all: plugin.o dltest

clean:
	rm -f dltest plugin.o

plugin.o:
	g++ -shared -o plugin.o plugin.cc

dltest:
	g++ -Wl,--export-dynamic -o dltest dltest.cc

--Boundary-01=_u0G1A6Log3OeQZZ
Content-Type: text/plain;
  charset="iso-8859-1";
  name="dltest.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="dltest.cc"

#include <dlfcn.h>

#include <iostream>

using namespace std;

int main()
{
	typedef void( *PluginFunction )();

	void *pluginHandle = dlopen( "./plugin.o", RTLD_LAZY );
	if ( !pluginHandle ) {
		cerr << dlerror() << endl;
		return 1;
	}

	PluginFunction pluginFunction = ( PluginFunction )dlsym( pluginHandle, "entry" );

	const char *error = dlerror();
	if ( error ) {
		cerr << error << endl;
		return 1;
	}

	pluginFunction();

	dlclose( pluginHandle );
}


--Boundary-01=_u0G1A6Log3OeQZZ
Content-Type: text/plain;
  charset="iso-8859-1";
  name="plugin.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="plugin.cc"

#include <string>
#include <iostream>
using namespace std;

extern "C" {

void entry()
{
	static std::string s;

	s = "Hi";

	cout << "Plugin says " << s << endl;
}

}

--Boundary-01=_u0G1A6Log3OeQZZ--

--Boundary-03=_u0G1A7ly03yeISI
Content-Type: application/pgp-signature
Content-Description: signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBA1G0uXhc68WspdLARAl2/AJ9/GXriMeBeooazWxQRFh2gKsXErgCfZed3
nrB9zIHrZBplPlwI/yXFBkM=
=H5Bd
-----END PGP SIGNATURE-----

--Boundary-03=_u0G1A7ly03yeISI--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406191843.26708.michaelnottebrock>