From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA21282; Thu, 8 Mar 2001 09:22:57 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA21387 for ; Thu, 8 Mar 2001 09:22:56 +0100 (MET) Received: from cremant.inria.fr (cremant.inria.fr [128.93.8.143]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f288Mrv15483; Thu, 8 Mar 2001 09:22:53 +0100 (MET) Received: (from lefessan@localhost) by cremant.inria.fr (8.11.0/8.11.0) id f288Mr513343; Thu, 8 Mar 2001 09:22:53 +0100 X-Authentication-Warning: cremant.inria.fr: lefessan set sender to fabrice.le_fessant@inria.fr using -f From: Fabrice Le Fessant MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15015.16731.108064.51473@cremant.inria.fr> Date: Thu, 8 Mar 2001 09:22:51 +0100 (CET) To: Chris Hecker Cc: caml-list@inria.fr Subject: Re: [Caml-list] dynamically loading C functions References: <4.3.2.7.2.20010304235205.00dea6a0@shell16.ba.best.com> <4.3.2.7.2.20010305164831.00e2cd60@shell16.ba.best.com> <4.3.2.7.2.20010306094319.00e2b8e0@shell16.ba.best.com> X-Mailer: VM 6.75 under Emacs 20.7.1 Reply-To: fabrice.le_fessant@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I've written a Dlopen module for x86 and alpha available at http://pauillac.inria.fr/~lefessan/src/dlopen.tar.gz It allows this kind of thing: cremant:~/devel/dlopen% ./top Objective Caml version 3.00+9 (2000-07-08) # open Dlopen;; # let dll = dlopen "./test.so" [RTLD_NOW];; val dll : Dlopen.dll = # let add_int = dlsym dll "add_int" "%d:%d%d";; val add_int : int -> int -> int = # let print_string = dlsym dll "print_string" "%d:%s";; val print_string : string -> int = # let add_double = dlsym dll "add_double" "%f:%f%f";; val add_double : float -> float -> float = # add_double (1.0) (2.0);; x: 1.000000 y: 2.000000 - : float = 3.000000 # print_string "bonjour";; bonjour - : int = 10 # add_int 1 2;; x: 1 y: 2 - : int = 3 # where test.c is: #include #include int add_int(int x, int y) { printf("x: %d y: %d\n",x,y); return x+y; } int print_string(char *s) { printf("%s\n", s); return 10;} double add_double(double x, double y) { printf("x: %f y: %f\n",x,y); return x+y;} - Fabrice ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr