[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't use dynamic-link with any shared object file
From: |
Eli Zaretskii |
Subject: |
Re: Can't use dynamic-link with any shared object file |
Date: |
Tue, 27 Dec 2016 08:18:44 +0200 |
> Date: Mon, 26 Dec 2016 22:24:21 +0000 (GMT)
> From: Jan Wedekind <address@hidden>
> Cc: address@hidden
>
> I think "libc" is normally loaded already. E.g. the C function "abs" can
> be accessed as follows:
>
> (define main (dynamic-link))
> (define cabs (pointer->procedure long (dynamic-func "abs" main) (list
> long)))
> (cabs -42)
> ; 42
This is non-portable, and doesn't work outside of the Posix world.
E.g., on MS-Windows (with Guile 2.0.x):
D:\usr\eli\data>guile
GNU Guile 2.0.11
Copyright (C) 1995-2014 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use (system foreign)
scheme@(guile-user)> ,use (rnrs bytevectors)
scheme@(guile-user)> (define main (dynamic-link))
scheme@(guile-user)> (define cabs (pointer->procedure long (dynamic-func
"abs" main) (list long)))
ERROR: In procedure dynamic-func:
ERROR: In procedure dynamic-pointer: Symbol not found: abs
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
But (msvcrt.dll is the C runtime library on Windows):
scheme@(guile-user)> (define libc (dynamic-link "msvcrt.dll"))
scheme@(guile-user)> (define cabs (pointer->procedure long (dynamic-func
"abs" libc) (list long)))
scheme@(guile-user)> (cabs -42)
$1 = 42
scheme@(guile-user)>