[plt-scheme] mzc mzscheme c-lambda c-declare (lib "cffi.ss" "compiler" ) troubleshoting

From: Ryan Culpepper (ryan_sml at yahoo.com)
Date: Mon Apr 5 06:58:34 EDT 2004

--- pbx tsx <pbx06 at hotmail.com> wrote:
> ...
> I encourted some problems when interfacing my scheme code with "the
> c code 
> of the UNIX crypt function".
> 
> 
> $>cat pass.scm
> (module crypt mzscheme
>   (require (lib "cffi.ss" "compiler" ))
>   (c-declare "#include <stdio.h>")
>   (c-declare "#include <time.h>")
>   (c-declare "#include <unistd.h>")
>   ;// char *crypt(const char *key, const char *salt) ;   //CRYPT(3)
>   (define crypt-me (c-lambda (char-string char-string) char-string
> "crypt"))
> )
> 
> $mzc pass.scm
> MzScheme compiler (mzc) version 206p1, Copyright (c) 2004 PLT
> Scheme, Inc.
> "pass.scm":
> [output to "./pass.so"]
> 
> $cat test.scm
> (load-extension "pass.so")
> (begin
>   (display (crypt "sa" "secret"))
>   (newline)
> )
> 
> $mzscheme -r test.scm
> load-extension: couldn't open "/home/pbx06/coding/pass.so" 
> (/home/pbx06/coding/pass.so: undefined symbol: crypt)

You probably just need to link in libcrypt. Try something like

  mzc ++ldf -lcrypt pass.scm

to compile your code.

Ryan


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/


Posted on the users mailing list.