* dynamic-link on libc
@ 2017-08-04 21:15 Jeff Mickey
2017-08-04 21:44 ` Matt Wette
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Mickey @ 2017-08-04 21:15 UTC (permalink / raw)
To: guile-user
Hi guilers!
I cannot seem to call `dynamic-link' on libc.
I'm trying to write a simple, dumb wrapper around syslog using the
(system foreign) dynamic library to learn how to use the dynamic
ffi.
(use-modules (system foreign))
(define libcsyslog (dynamic-link "libc")) (define syslog
(let ((f (pointer->procedure
void (dynamic-func "syslog" libcsyslog) (list int
'*))))
(lambda (level msg)
(let* ((clevel level)
(cmsg (string->pointer msg))) (f clevel cmsg)))))
(syslog 3 "hello there")
This works when I symlink /lib/x86_64-linux-gnu/libc.so.6 to
libc.so, but it looks like the libtool library that is doing the
load doesn't accept names that end in ".6" as a library name, and
when I used the full path it just says "file not found".
Anyone have suggestions? I looked at the dynl.c sysdep_dynl_link
function, but I'm not sure I understand libtool well enough to
know what lt_dlopenext should be doing.
I should add I tested this on a debian system with a debian
provided guile, and a "user installed guix" guile install as well.
Thanks!
// codemac
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dynamic-link on libc
2017-08-04 21:15 dynamic-link on libc Jeff Mickey
@ 2017-08-04 21:44 ` Matt Wette
2017-08-04 22:12 ` Jeff Mickey
0 siblings, 1 reply; 3+ messages in thread
From: Matt Wette @ 2017-08-04 21:44 UTC (permalink / raw)
To: Jeff Mickey; +Cc: guile-user
> On Aug 4, 2017, at 2:15 PM, Jeff Mickey <j@codemac.net> wrote:
>
> Hi guilers!
>
> I cannot seem to call `dynamic-link' on libc.
>
> I'm trying to write a simple, dumb wrapper around syslog using the (system foreign) dynamic library to learn how to use the dynamic ffi.
>
> (use-modules (system foreign))
> (define libcsyslog (dynamic-link "libc")) (define syslog (let ((f (pointer->procedure void (dynamic-func "syslog" libcsyslog) (list int '*)))) (lambda (level msg) (let* ((clevel level) (cmsg (string->pointer msg))) (f clevel cmsg))))) (syslog 3 "hello there")
>
> This works when I symlink /lib/x86_64-linux-gnu/libc.so.6 to libc.so, but it looks like the libtool library that is doing the load doesn't accept names that end in ".6" as a library name, and when I used the full path it just says "file not found".
>
> Anyone have suggestions? I looked at the dynl.c sysdep_dynl_link function, but I'm not sure I understand libtool well enough to know what lt_dlopenext should be doing.
>
> I should add I tested this on a debian system with a debian provided guile, and a "user installed guix" guile install as well.
>
> Thanks!
>
> // codemac
>
I don’t think you need to dynamic-link libc; just use (dynamic-func "syslog" (dynamic-link)).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dynamic-link on libc
2017-08-04 21:44 ` Matt Wette
@ 2017-08-04 22:12 ` Jeff Mickey
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Mickey @ 2017-08-04 22:12 UTC (permalink / raw)
To: Matt Wette; +Cc: guile-user
That solves my problem! Thank you so much :)
libc is a special case, and I should have thought about it more.
// mickey
On Fri, Aug 4, 2017, at 14:44, Matt Wette wrote:
>
> > On Aug 4, 2017, at 2:15 PM, Jeff Mickey <j@codemac.net> wrote:
> >
> > Hi guilers!
> >
> > I cannot seem to call `dynamic-link' on libc.
> >
> > I'm trying to write a simple, dumb wrapper around syslog using the (system foreign) dynamic library to learn how to use the dynamic ffi.
> >
> > (use-modules (system foreign))
> > (define libcsyslog (dynamic-link "libc")) (define syslog (let ((f (pointer->procedure void (dynamic-func "syslog" libcsyslog) (list int '*)))) (lambda (level msg) (let* ((clevel level) (cmsg (string->pointer msg))) (f clevel cmsg))))) (syslog 3 "hello there")
> >
> > This works when I symlink /lib/x86_64-linux-gnu/libc.so.6 to libc.so, but it looks like the libtool library that is doing the load doesn't accept names that end in ".6" as a library name, and when I used the full path it just says "file not found".
> >
> > Anyone have suggestions? I looked at the dynl.c sysdep_dynl_link function, but I'm not sure I understand libtool well enough to know what lt_dlopenext should be doing.
> >
> > I should add I tested this on a debian system with a debian provided guile, and a "user installed guix" guile install as well.
> >
> > Thanks!
> >
> > // codemac
> >
>
> I don’t think you need to dynamic-link libc; just use (dynamic-func
> "syslog" (dynamic-link)).
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-04 22:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-04 21:15 dynamic-link on libc Jeff Mickey
2017-08-04 21:44 ` Matt Wette
2017-08-04 22:12 ` Jeff Mickey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).