Re: [racket-users] student produces absolutely bonkers environment lookup code

2021-05-07 Thread Ben Greenman
On 5/7/21, Shu-Hung You  wrote:
> Not that I have any idea of what's going on, but interestingly, Typed
> Racket's second ->* example has (1)(3)(4). The use of list* may be
> possible if one follows the type (List* String Natural x) in the
> example.
>
> https://docs.racket-lang.org/ts-reference/type-ref.html?#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%2A%29%29
>
> Shu-Hung

+1, that example in the docs looks _very_ similar to the student code

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R4SJ7OisUeH5mFxGHpycrxhKYNFuSMLLgSzKCprt2aQWQ%40mail.gmail.com.


Re: [racket-users] student produces absolutely bonkers environment lookup code

2021-05-07 Thread Shu-Hung You
Not that I have any idea of what's going on, but interestingly, Typed
Racket's second ->* example has (1)(3)(4). The use of list* may be
possible if one follows the type (List* String Natural x) in the
example.

https://docs.racket-lang.org/ts-reference/type-ref.html?#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%2A%29%29

Shu-Hung

On Fri, May 7, 2021 at 10:53 AM 'John Clements' via Racket Users
 wrote:
>
> Background: I teach a PL course, using Shriram’s PLAI. Many of the 
> assignments require students to maintain an environment mapping symbols to 
> values. Shriram illustrates a nice easy way to do this, as a list of 
> two-element structures. You can also use an immutable hash. Fine. So I’m 
> grading a student submission, and I come across this:
>
> (: extend-environment* (-> Environment (Listof (List Symbol Value)) 
> Environment))
> (define (extend-environment* env kv)
>   (let loop ([kv : (Listof (List Symbol Value)) kv]
>  [env env])
> (cond
>   [(empty? kv) env]
>   [else
>(let* ([kv-pair (first kv)]
>   [new-env (KVEnvironment (first kv-pair) (second kv-pair) env)])
>  (loop (rest kv) new-env))])))
>
>
> ;; Returns a new environment with old-env as parent
> (: extend-environment (->* (Environment Symbol Value) #:rest-star (Symbol 
> Value) Environment))
> (define (extend-environment env key value . kv)
>   (define kv* : (Listof (List Symbol Value))
> (let loop : (Listof (List Symbol Value))
>   ([kv : (Rec x (U Null (List* Symbol Value x))) (list* key value kv)])
>   (if (empty? kv)
>   '()
>   (let* ([take-two (list (first kv) (second kv))]
>  [drop-two (rest (rest kv))])
> (list* take-two (loop drop-two))
>   (extend-environment* env kv*))
>
> This solution uses
>
> 1) a named let,
> 2) the list* function,
> 3) a ->* type with a #:rest-star argument, and
> 4) A custom rec type for alternating symbols and values.
>
> To cap it all off, the student DOESN’T EVEN USE the extra hardware. This is 
> the only use of extend-environment in the code:
>
> (extend-environment e name arg)
>
> So, uh, any idea where this code came from?
>
> :)
>
> John
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/ee31119c-aab4-48e4-94dd-39272dd34724%40mtasv.net.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAMTzy%2BZDuZbSW3ga%2BeDdiXhfgJSZpNS2u_nhB%2Bj9u40tYKXJKQ%40mail.gmail.com.


[racket-users] student produces absolutely bonkers environment lookup code

2021-05-07 Thread 'John Clements' via Racket Users
Background: I teach a PL course, using Shriram’s PLAI. Many of the assignments 
require students to maintain an environment mapping symbols to values. Shriram 
illustrates a nice easy way to do this, as a list of two-element structures. 
You can also use an immutable hash. Fine. So I’m grading a student submission, 
and I come across this:

(: extend-environment* (-> Environment (Listof (List Symbol Value)) 
Environment))
(define (extend-environment* env kv)
  (let loop ([kv : (Listof (List Symbol Value)) kv]
 [env env])
(cond
  [(empty? kv) env]
  [else
   (let* ([kv-pair (first kv)]
  [new-env (KVEnvironment (first kv-pair) (second kv-pair) env)])
 (loop (rest kv) new-env))])))


;; Returns a new environment with old-env as parent
(: extend-environment (->* (Environment Symbol Value) #:rest-star (Symbol 
Value) Environment))
(define (extend-environment env key value . kv)
  (define kv* : (Listof (List Symbol Value))
(let loop : (Listof (List Symbol Value))
  ([kv : (Rec x (U Null (List* Symbol Value x))) (list* key value kv)])
  (if (empty? kv)
  '()
  (let* ([take-two (list (first kv) (second kv))]
 [drop-two (rest (rest kv))])
(list* take-two (loop drop-two))
  (extend-environment* env kv*))

This solution uses

1) a named let,
2) the list* function,
3) a ->* type with a #:rest-star argument, and
4) A custom rec type for alternating symbols and values.

To cap it all off, the student DOESN’T EVEN USE the extra hardware. This is the 
only use of extend-environment in the code:

(extend-environment e name arg)

So, uh, any idea where this code came from? 

:)

John 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/ee31119c-aab4-48e4-94dd-39272dd34724%40mtasv.net.


Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread krs...@gmail.com
This is fun :)
I unset the LD_LIBRARY_PATH and added the lib-search-dirs back to the 
config and 

> (require taglib)
ffi-lib: failed for (ffi-lib "libtag_c" '("0")), tried: 
  # (no such 
file)
  # (no such file)
  # (no such file)
  # (no such file)
  # (exists)
  # (no such file)
  "libtag_c.so.0" (using OS library search path)
  "libtag_c" (using OS library search path)
  # (no such file)
  # (no such file)
; ffi-lib: could not load foreign library
;   path: libtag_c.so.0
;   system error: File not found
; [,bt for context]
> 


Look at that "exists" ...


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2808a892-fd7c-4463-b2ce-5454b7a61321n%40googlegroups.com.


Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread Ryan Culpepper
Sorry, I did miss those emails.

What do you see if you try (require taglib) after starting Racket with
logging for "ffi-lib"? For example:

  $ PLTSTDERR="debug@ffi-lib" racket
   unrelated logging 
  > (require taglib)
  ???

If it lists the file you pointed to in your email and says "(exists)", then
the problem is probably that loading fails because libtag_c.so.0 depends on
another shared library, and the dependency couldn't be found. On Linux, I
would inspect shared library dependencies with the ldd command, but I don't
know what to use on OpenBSD.

---

I see that setting LD_LIBRARY_PATH worked for you. The difference between
Racket's search path (reported by get-lib-search-dirs) and the OS search
path (which LD_LIBRARY_PATH extends) is that Racket's search path only
applies to shared libraries loaded directly from Racket using ffi-lib; it
doesn't apply to any other shared libraries that they depend on.

Ryan


On Fri, May 7, 2021 at 5:03 PM krs...@gmail.com  wrote:

> Thanks for your help all!
> I think you didn't see my last 2 replies.
>
> I compiled taglib locally and set the library include path as seen in the
> racket REPL output.
> I shouldn't need to do the symlink because my version is now the exact
> same file name as the REPL says cant be found.
> (I it anyway, and it says same error file doesnt exist)
>
> Also I ran:
> (get-lib-search-dirs)
> '(#
>   #
>   #)  <-- LOOK AT THE DIR
>
> The actaul file name that it says it cannot find is in that directory.
> wise@dug:/home/wise$ ls -1 /home/wise/root/lib/   <--
> THIS IS IN MY "lib-search-dirs"
>
>
> libtag.a
> libtag.so.1
> libtag.so.1.18.0
> libtag_c.a
> libtag_c.so.0   <-- THIS IS THE FILE IT SAYS CANNOT BE FOUND
> libtag_c.so.0.0.0
> pkgconfig
>
>
> > (require taglib)
> ; ffi-lib: could not load foreign library
> ;   path: libtag_c.so.0   <-- SAYS IT CANNOT FIND THIS FILE
> ;   system error: File not found
>
>
>
> On Friday, May 7, 2021 at 10:29:21 AM UTC-4 rmculp...@gmail.com wrote:
>
>> It looks like there are two issues. One is the shared library's
>> directory, but the other is that the Racket library is looking for
>> "libtag_c.so.0", and you have "libtag_c.so.3.0". That is, it's looking for
>> a version suffix of "0", not "3.0" (see
>> https://github.com/takikawa/taglib-racket/blob/master/taglib/taglib.rkt#L83
>> ).
>>
>> One fix would be to change the Racket code to try "3.0" also. Maybe
>> conditioned on the OS, since on Ubuntu I also get the library with suffix
>> "0".
>>
>> An alternative would be to copy or link /usr/local/lib/libtag_c.so.3.0 to
>> Racket's lib directory with the file name the Racket code is trying to load:
>>
>>   ln -s /usr/local/lib/libtag_c.so.3.0
>> ~/.local/share/racket/7.9/lib/libtag_c.so.0
>>
>> Note: that assumes that the library versions are actually compatible;
>> otherwise, the Racket code is likely to misbehave, even if it loads the
>> library. Loading the shared library might still fail if the shared library
>> itself has dependencies that are not in the default OS search path. (In
>> that case, Nate's point about LD_LIBRARY_PATH might help.)
>>
>> Ryan
>>
>>
>> On Fri, May 7, 2021 at 3:12 PM krs...@gmail.com  wrote:
>>
>>> I know it sees my custom dir, I ran this in racket:
>>> > (require setup/dirs)
>>> > (get-lib-search-dirs)
>>> '(#
>>>   #
>>>   #)
>>>
>>>
>>> On Friday, May 7, 2021 at 8:08:26 AM UTC-4 krs...@gmail.com wrote:
>>>
 I'm so close :)

 I installed taglib locally to /home/wise/root/lib, so I *have* the file
 exactly as racket is complaining about:
 /home/wise/root/lib/libtag_c.so.0

 I used your config example to edit (as root) /etc/racket/config.rktd
 I added the "lib-search-dirs" line, so it looks like:
 ;; generated by unixstyle-install
 #hash(
   (doc-dir . "/usr/local/share/doc/racket")
   (lib-dir . "/usr/local/lib/racket")
   (share-dir . "/usr/local/share/racket")
   (include-dir . "/usr/local/include/racket")
   (bin-dir . "/usr/local/bin")
   (apps-dir . "/usr/local/share/applications")
   (man-dir . "/usr/local/man")
   (absolute-installation? . #t)
   (build-stamp . "")
   (doc-search-url . "
 https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html
 ")
   (catalogs . ("
 https://download.racket-lang.org/releases/7.9/catalog/;))
   (lib-search-dirs . (#f "/home/wise/root/lib"))
 )

 I still get the error:
 Welcome to Racket v7.9 [cs].

 > (require taglib)
 ; ffi-lib: could not load foreign library
 ;   path: libtag_c.so.0
 ;   system error: File not found
 ; [,bt for context]

 I'm still poking at it, thanks again for the help.

 On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:

> Thanks for the help!
> I was sure that was going to be it but it's not :(
>
> This is what is on my 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread krs...@gmail.com
OK ok ok, I did what na...@manicmind.earth said:

wise@dug:/home/wise$ export 
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/wise/root/lib" 
wise@dug:/home/wise$ 
racket
Welcome to Racket v7.9 [cs].
> (require taglib)
> 


SUCCESS :)

(I think something in the lib-search-dirs stuff isn't doing what it's 
supposed to, maybe if I get motivated i'll investigate more.)

Thanks again! 


On Friday, May 7, 2021 at 11:03:15 AM UTC-4 krs...@gmail.com wrote:

> Thanks for your help all!
> I think you didn't see my last 2 replies.
>
> I compiled taglib locally and set the library include path as seen in the 
> racket REPL output.
> I shouldn't need to do the symlink because my version is now the exact 
> same file name as the REPL says cant be found.
> (I it anyway, and it says same error file doesnt exist)
>
> Also I ran:
> (get-lib-search-dirs)
> '(#
>   #
>   #)  <-- LOOK AT THE DIR
>
> The actaul file name that it says it cannot find is in that directory.
> wise@dug:/home/wise$ ls -1 /home/wise/root/lib/   <-- 
> THIS IS IN MY "lib-search-dirs" 
>   
>  
>
> libtag.a
> libtag.so.1
> libtag.so.1.18.0
> libtag_c.a
> libtag_c.so.0   <-- THIS IS THE FILE IT SAYS CANNOT BE FOUND
> libtag_c.so.0.0.0
> pkgconfig
>
>
> > (require taglib)
> ; ffi-lib: could not load foreign library
> ;   path: libtag_c.so.0   <-- SAYS IT CANNOT FIND THIS FILE
>
> ;   system error: File not found
>
>
>
> On Friday, May 7, 2021 at 10:29:21 AM UTC-4 rmculp...@gmail.com wrote:
>
>> It looks like there are two issues. One is the shared library's 
>> directory, but the other is that the Racket library is looking for 
>> "libtag_c.so.0", and you have "libtag_c.so.3.0". That is, it's looking for 
>> a version suffix of "0", not "3.0" (see 
>> https://github.com/takikawa/taglib-racket/blob/master/taglib/taglib.rkt#L83
>> ).
>>
>> One fix would be to change the Racket code to try "3.0" also. Maybe 
>> conditioned on the OS, since on Ubuntu I also get the library with suffix 
>> "0".
>>
>> An alternative would be to copy or link /usr/local/lib/libtag_c.so.3.0 to 
>> Racket's lib directory with the file name the Racket code is trying to load:
>>
>>   ln -s /usr/local/lib/libtag_c.so.3.0 
>> ~/.local/share/racket/7.9/lib/libtag_c.so.0
>>
>> Note: that assumes that the library versions are actually compatible; 
>> otherwise, the Racket code is likely to misbehave, even if it loads the 
>> library. Loading the shared library might still fail if the shared library 
>> itself has dependencies that are not in the default OS search path. (In 
>> that case, Nate's point about LD_LIBRARY_PATH might help.)
>>
>> Ryan
>>
>>
>> On Fri, May 7, 2021 at 3:12 PM krs...@gmail.com  wrote:
>>
>>> I know it sees my custom dir, I ran this in racket:
>>> > (require setup/dirs)
>>> > (get-lib-search-dirs)
>>> '(#
>>>   #
>>>   #)
>>>
>>>
>>> On Friday, May 7, 2021 at 8:08:26 AM UTC-4 krs...@gmail.com wrote:
>>>
 I'm so close :)

 I installed taglib locally to /home/wise/root/lib, so I *have* the file 
 exactly as racket is complaining about:
 /home/wise/root/lib/libtag_c.so.0

 I used your config example to edit (as root) /etc/racket/config.rktd
 I added the "lib-search-dirs" line, so it looks like:
 ;; generated by unixstyle-install
 #hash(
   (doc-dir . "/usr/local/share/doc/racket")
   (lib-dir . "/usr/local/lib/racket")
   (share-dir . "/usr/local/share/racket")
   (include-dir . "/usr/local/include/racket")
   (bin-dir . "/usr/local/bin")
   (apps-dir . "/usr/local/share/applications")
   (man-dir . "/usr/local/man")
   (absolute-installation? . #t)
   (build-stamp . "")
   (doc-search-url . "
 https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html
 ")
   (catalogs . ("
 https://download.racket-lang.org/releases/7.9/catalog/;))
   (lib-search-dirs . (#f "/home/wise/root/lib"))
 )

 I still get the error:
 Welcome to Racket v7.9 [cs].

 > (require taglib)
 ; ffi-lib: could not load foreign library
 ;   path: libtag_c.so.0
 ;   system error: File not found
 ; [,bt for context]

 I'm still poking at it, thanks again for the help.

 On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:

> Thanks for the help!
> I was sure that was going to be it but it's not :(
>
> This is what is on my system:
> /usr/local/lib/libtag_c.so.3.0
>
> racket is looking for libtag_c.so.0
>
> So i'm not sure what to do next.
>
> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
>
>> It looks to me like you probably need to edit your “config.rktd” 
>> file: 
>>
>>
>> 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread krs...@gmail.com
Thanks for your help all!
I think you didn't see my last 2 replies.

I compiled taglib locally and set the library include path as seen in the 
racket REPL output.
I shouldn't need to do the symlink because my version is now the exact same 
file name as the REPL says cant be found.
(I it anyway, and it says same error file doesnt exist)

Also I ran:
(get-lib-search-dirs)
'(#
  #
  #)  <-- LOOK AT THE DIR

The actaul file name that it says it cannot find is in that directory.
wise@dug:/home/wise$ ls -1 /home/wise/root/lib/   <-- 
THIS IS IN MY "lib-search-dirs" 

   

libtag.a
libtag.so.1
libtag.so.1.18.0
libtag_c.a
libtag_c.so.0   <-- THIS IS THE FILE IT SAYS CANNOT BE FOUND
libtag_c.so.0.0.0
pkgconfig


> (require taglib)
; ffi-lib: could not load foreign library
;   path: libtag_c.so.0   <-- SAYS IT CANNOT FIND THIS FILE
;   system error: File not found



On Friday, May 7, 2021 at 10:29:21 AM UTC-4 rmculp...@gmail.com wrote:

> It looks like there are two issues. One is the shared library's directory, 
> but the other is that the Racket library is looking for "libtag_c.so.0", 
> and you have "libtag_c.so.3.0". That is, it's looking for a version suffix 
> of "0", not "3.0" (see 
> https://github.com/takikawa/taglib-racket/blob/master/taglib/taglib.rkt#L83
> ).
>
> One fix would be to change the Racket code to try "3.0" also. Maybe 
> conditioned on the OS, since on Ubuntu I also get the library with suffix 
> "0".
>
> An alternative would be to copy or link /usr/local/lib/libtag_c.so.3.0 to 
> Racket's lib directory with the file name the Racket code is trying to load:
>
>   ln -s /usr/local/lib/libtag_c.so.3.0 
> ~/.local/share/racket/7.9/lib/libtag_c.so.0
>
> Note: that assumes that the library versions are actually compatible; 
> otherwise, the Racket code is likely to misbehave, even if it loads the 
> library. Loading the shared library might still fail if the shared library 
> itself has dependencies that are not in the default OS search path. (In 
> that case, Nate's point about LD_LIBRARY_PATH might help.)
>
> Ryan
>
>
> On Fri, May 7, 2021 at 3:12 PM krs...@gmail.com  wrote:
>
>> I know it sees my custom dir, I ran this in racket:
>> > (require setup/dirs)
>> > (get-lib-search-dirs)
>> '(#
>>   #
>>   #)
>>
>>
>> On Friday, May 7, 2021 at 8:08:26 AM UTC-4 krs...@gmail.com wrote:
>>
>>> I'm so close :)
>>>
>>> I installed taglib locally to /home/wise/root/lib, so I *have* the file 
>>> exactly as racket is complaining about:
>>> /home/wise/root/lib/libtag_c.so.0
>>>
>>> I used your config example to edit (as root) /etc/racket/config.rktd
>>> I added the "lib-search-dirs" line, so it looks like:
>>> ;; generated by unixstyle-install
>>> #hash(
>>>   (doc-dir . "/usr/local/share/doc/racket")
>>>   (lib-dir . "/usr/local/lib/racket")
>>>   (share-dir . "/usr/local/share/racket")
>>>   (include-dir . "/usr/local/include/racket")
>>>   (bin-dir . "/usr/local/bin")
>>>   (apps-dir . "/usr/local/share/applications")
>>>   (man-dir . "/usr/local/man")
>>>   (absolute-installation? . #t)
>>>   (build-stamp . "")
>>>   (doc-search-url . "
>>> https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html
>>> ")
>>>   (catalogs . ("
>>> https://download.racket-lang.org/releases/7.9/catalog/;))
>>>   (lib-search-dirs . (#f "/home/wise/root/lib"))
>>> )
>>>
>>> I still get the error:
>>> Welcome to Racket v7.9 [cs].
>>>
>>> > (require taglib)
>>> ; ffi-lib: could not load foreign library
>>> ;   path: libtag_c.so.0
>>> ;   system error: File not found
>>> ; [,bt for context]
>>>
>>> I'm still poking at it, thanks again for the help.
>>>
>>> On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:
>>>
 Thanks for the help!
 I was sure that was going to be it but it's not :(

 This is what is on my system:
 /usr/local/lib/libtag_c.so.3.0

 racket is looking for libtag_c.so.0

 So i'm not sure what to do next.

 On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:

> It looks to me like you probably need to edit your “config.rktd” file: 
>
>
> https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29
>  
>
> On my machine (macOS using macports), for instance I have do do this 
> for every new installation of drracket: 
>
> - edit /config.rktd to contain 
> (lib-search-dirs . (#f "/opt/local/lib”)) 
>
> Let me know if I misunderstood your situation! 
>
> John Clements 
>
>
> > On May 6, 2021, at 3:54 AM, krs...@gmail.com  
> wrote: 
> > 
> > 
> > Hi!, 
> > 
> > I am doing: (require taglib) and I get: 
> > > (require taglib) 
> > ; ffi-lib: could not load foreign library 
> > ; path: 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread Ryan Culpepper
It looks like there are two issues. One is the shared library's directory,
but the other is that the Racket library is looking for "libtag_c.so.0",
and you have "libtag_c.so.3.0". That is, it's looking for a version suffix
of "0", not "3.0" (see
https://github.com/takikawa/taglib-racket/blob/master/taglib/taglib.rkt#L83
).

One fix would be to change the Racket code to try "3.0" also. Maybe
conditioned on the OS, since on Ubuntu I also get the library with suffix
"0".

An alternative would be to copy or link /usr/local/lib/libtag_c.so.3.0 to
Racket's lib directory with the file name the Racket code is trying to load:

  ln -s /usr/local/lib/libtag_c.so.3.0
~/.local/share/racket/7.9/lib/libtag_c.so.0

Note: that assumes that the library versions are actually compatible;
otherwise, the Racket code is likely to misbehave, even if it loads the
library. Loading the shared library might still fail if the shared library
itself has dependencies that are not in the default OS search path. (In
that case, Nate's point about LD_LIBRARY_PATH might help.)

Ryan


On Fri, May 7, 2021 at 3:12 PM krs...@gmail.com  wrote:

> I know it sees my custom dir, I ran this in racket:
> > (require setup/dirs)
> > (get-lib-search-dirs)
> '(#
>   #
>   #)
>
>
> On Friday, May 7, 2021 at 8:08:26 AM UTC-4 krs...@gmail.com wrote:
>
>> I'm so close :)
>>
>> I installed taglib locally to /home/wise/root/lib, so I *have* the file
>> exactly as racket is complaining about:
>> /home/wise/root/lib/libtag_c.so.0
>>
>> I used your config example to edit (as root) /etc/racket/config.rktd
>> I added the "lib-search-dirs" line, so it looks like:
>> ;; generated by unixstyle-install
>> #hash(
>>   (doc-dir . "/usr/local/share/doc/racket")
>>   (lib-dir . "/usr/local/lib/racket")
>>   (share-dir . "/usr/local/share/racket")
>>   (include-dir . "/usr/local/include/racket")
>>   (bin-dir . "/usr/local/bin")
>>   (apps-dir . "/usr/local/share/applications")
>>   (man-dir . "/usr/local/man")
>>   (absolute-installation? . #t)
>>   (build-stamp . "")
>>   (doc-search-url . "
>> https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html
>> ")
>>   (catalogs . ("
>> https://download.racket-lang.org/releases/7.9/catalog/;))
>>   (lib-search-dirs . (#f "/home/wise/root/lib"))
>> )
>>
>> I still get the error:
>> Welcome to Racket v7.9 [cs].
>>
>> > (require taglib)
>> ; ffi-lib: could not load foreign library
>> ;   path: libtag_c.so.0
>> ;   system error: File not found
>> ; [,bt for context]
>>
>> I'm still poking at it, thanks again for the help.
>>
>> On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:
>>
>>> Thanks for the help!
>>> I was sure that was going to be it but it's not :(
>>>
>>> This is what is on my system:
>>> /usr/local/lib/libtag_c.so.3.0
>>>
>>> racket is looking for libtag_c.so.0
>>>
>>> So i'm not sure what to do next.
>>>
>>> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
>>>
 It looks to me like you probably need to edit your “config.rktd” file:


 https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29

 On my machine (macOS using macports), for instance I have do do this
 for every new installation of drracket:

 - edit /config.rktd to contain
 (lib-search-dirs . (#f "/opt/local/lib”))

 Let me know if I misunderstood your situation!

 John Clements


 > On May 6, 2021, at 3:54 AM, krs...@gmail.com 
 wrote:
 >
 >
 > Hi!,
 >
 > I am doing: (require taglib) and I get:
 > > (require taglib)
 > ; ffi-lib: could not load foreign library
 > ; path: libtag_c.so.0
 > ; system error: File not found
 > ; [,bt for context]
 >
 > I am on OpenBSD and that file is at:
 > /usr/local/lib/libtag_c.so.3.0
 >
 > How can I change my search path for C libs to be /usr/local ?
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups "Racket Users" group.
 > To unsubscribe from this group and stop receiving emails from it,
 send an email to racket-users...@googlegroups.com.
 > To view this discussion on the web visit
 https://groups.google.com/d/msgid/racket-users/b8425f0a-6d45-4954-9e32-df51aa5151cbn%40googlegroups.com.


 --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/59a44f94-5931-46cd-ba3b-039c02a47076n%40googlegroups.com
> 
> .
>

-- 
You received this message 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread Nathaniel W Griswold
Also, i think in the past there were security limits in Mac OS X that prevented 
adjusting the dynamic library load path. I think maybe that's why i didn’t use 
them but things seem to be working through the env vars without any user 
changes to the default system security settings on my system, which is Big Sur 
11.3.1.

Nate

> On May 7, 2021, at 8:53 AM, Nathaniel W Griswold  wrote:
> 
> Folks,
> 
> One other thing you can do that might work here is to set an environment 
> variable for yourself. I don’t remember the exact details of how libraries 
> are looked up but on my system (mac os) i can do something like:
> 
> 
> % ls /opt/local/lib/libtag_c.*
> /opt/local/lib/libtag_c.0.0.0.dylib   /opt/local/lib/libtag_c.0.dylib 
> /opt/local/lib/libtag_c.dylib
> 
> % export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
> % racket
> Welcome to Racket v7.9 [cs].
>> (require taglib)
> 
> (success)
> 
> On BSD or linux i guess you can check `man ldconfig` and set something like 
> LD_LIBRARY_PATH, or maybe there’s something a little closer to mac os x’s 
> DYLD_FALLBACK_LIBRARY_PATH which i think works a little better (see 
> https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s/3172515#3172515
>  )
> 
> Did you already try `export 
> LD_LIBRARY_PATH=“$LD_LIBRARY_PATH:/usr/local/lib/"` ?
> 
> As for what John Clements said, I think in the past i have also set up the 
> config.rktd in the exact same way, but i do not remember the details of the 
> difference between the two methods. It seems to me that the environment 
> variable method might be a little more flexible for chained loads, as it 
> seems that if a c program were to load a dynamic library programmatically it 
> simply would not know what your racket settings were. I guess another benefit 
> is you don’t have to edit the system config.rktd, which doesn’t really seem 
> like it’s meant to be changed unless you are specifying an entirely new 
> PLTCONFIGDIR (or —config, or -G).
> 
> Maybe others can better elucidate pros/cons of 
> 
>> On May 7, 2021, at 7:08 AM, krs...@gmail.com  wrote:
>> 
>> I'm so close :)
>> 
>> I installed taglib locally to /home/wise/root/lib, so I *have* the file 
>> exactly as racket is complaining about:
>> /home/wise/root/lib/libtag_c.so.0
>> 
>> I used your config example to edit (as root) /etc/racket/config.rktd
>> I added the "lib-search-dirs" line, so it looks like:
>> ;; generated by unixstyle-install
>> #hash(
>>  (doc-dir . "/usr/local/share/doc/racket")
>>  (lib-dir . "/usr/local/lib/racket")
>>  (share-dir . "/usr/local/share/racket")
>>  (include-dir . "/usr/local/include/racket")
>>  (bin-dir . "/usr/local/bin")
>>  (apps-dir . "/usr/local/share/applications")
>>  (man-dir . "/usr/local/man")
>>  (absolute-installation? . #t)
>>  (build-stamp . "")
>>  (doc-search-url . 
>> "https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html;)
>>  (catalogs . ("https://download.racket-lang.org/releases/7.9/catalog/;))
>>  (lib-search-dirs . (#f "/home/wise/root/lib"))
>> )
>> 
>> I still get the error:
>> Welcome to Racket v7.9 [cs].
>>> (require taglib)
>> ; ffi-lib: could not load foreign library
>> ;   path: libtag_c.so.0
>> ;   system error: File not found
>> ; [,bt for context]
>> 
>> I'm still poking at it, thanks again for the help.
>> 
>> On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:
>> Thanks for the help!
>> I was sure that was going to be it but it's not :(
>> 
>> This is what is on my system:
>> /usr/local/lib/libtag_c.so.3.0
>> 
>> racket is looking for libtag_c.so.0
>> 
>> So i'm not sure what to do next.
>> 
>> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
>> It looks to me like you probably need to edit your “config.rktd” file: 
>> 
>> https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29
>>  
>> 
>> On my machine (macOS using macports), for instance I have do do this for 
>> every new installation of drracket: 
>> 
>> - edit /config.rktd to contain 
>> (lib-search-dirs . (#f "/opt/local/lib”)) 
>> 
>> Let me know if I misunderstood your situation! 
>> 
>> John Clements 
>> 
>> 
>>> On May 6, 2021, at 3:54 AM, krs...@gmail.com  wrote: 
>>> 
>>> 
>>> Hi!, 
>>> 
>>> I am doing: (require taglib) and I get: 
 (require taglib) 
>>> ; ffi-lib: could not load foreign library 
>>> ; path: libtag_c.so.0 
>>> ; system error: File not found 
>>> ; [,bt for context] 
>>> 
>>> I am on OpenBSD and that file is at: 
>>> /usr/local/lib/libtag_c.so.3.0 
>>> 
>>> How can I change my search path for C libs to be /usr/local ? 
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Racket Users" group. 
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread Nathaniel W Griswold
Folks,

One other thing you can do that might work here is to set an environment 
variable for yourself. I don’t remember the exact details of how libraries are 
looked up but on my system (mac os) i can do something like:


% ls /opt/local/lib/libtag_c.*
/opt/local/lib/libtag_c.0.0.0.dylib /opt/local/lib/libtag_c.0.dylib 
/opt/local/lib/libtag_c.dylib

% export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib
% racket
Welcome to Racket v7.9 [cs].
> (require taglib)

(success)

On BSD or linux i guess you can check `man ldconfig` and set something like 
LD_LIBRARY_PATH, or maybe there’s something a little closer to mac os x’s 
DYLD_FALLBACK_LIBRARY_PATH which i think works a little better (see 
https://stackoverflow.com/questions/3146274/is-it-ok-to-use-dyld-library-path-on-mac-os-x-and-whats-the-dynamic-library-s/3172515#3172515
 )

Did you already try `export LD_LIBRARY_PATH=“$LD_LIBRARY_PATH:/usr/local/lib/"` 
?

As for what John Clements said, I think in the past i have also set up the 
config.rktd in the exact same way, but i do not remember the details of the 
difference between the two methods. It seems to me that the environment 
variable method might be a little more flexible for chained loads, as it seems 
that if a c program were to load a dynamic library programmatically it simply 
would not know what your racket settings were. I guess another benefit is you 
don’t have to edit the system config.rktd, which doesn’t really seem like it’s 
meant to be changed unless you are specifying an entirely new PLTCONFIGDIR (or 
—config, or -G).

Maybe others can better elucidate pros/cons of 

> On May 7, 2021, at 7:08 AM, krs...@gmail.com  wrote:
> 
> I'm so close :)
> 
> I installed taglib locally to /home/wise/root/lib, so I *have* the file 
> exactly as racket is complaining about:
> /home/wise/root/lib/libtag_c.so.0
> 
> I used your config example to edit (as root) /etc/racket/config.rktd
> I added the "lib-search-dirs" line, so it looks like:
> ;; generated by unixstyle-install
> #hash(
>   (doc-dir . "/usr/local/share/doc/racket")
>   (lib-dir . "/usr/local/lib/racket")
>   (share-dir . "/usr/local/share/racket")
>   (include-dir . "/usr/local/include/racket")
>   (bin-dir . "/usr/local/bin")
>   (apps-dir . "/usr/local/share/applications")
>   (man-dir . "/usr/local/man")
>   (absolute-installation? . #t)
>   (build-stamp . "")
>   (doc-search-url . 
> "https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html;)
>   (catalogs . ("https://download.racket-lang.org/releases/7.9/catalog/;))
>   (lib-search-dirs . (#f "/home/wise/root/lib"))
> )
> 
> I still get the error:
> Welcome to Racket v7.9 [cs].
> > (require taglib)
> ; ffi-lib: could not load foreign library
> ;   path: libtag_c.so.0
> ;   system error: File not found
> ; [,bt for context]
> 
> I'm still poking at it, thanks again for the help.
> 
> On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:
> Thanks for the help!
> I was sure that was going to be it but it's not :(
> 
> This is what is on my system:
> /usr/local/lib/libtag_c.so.3.0
> 
> racket is looking for libtag_c.so.0
> 
> So i'm not sure what to do next.
> 
> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
> It looks to me like you probably need to edit your “config.rktd” file: 
> 
> https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29
>  
> 
> On my machine (macOS using macports), for instance I have do do this for 
> every new installation of drracket: 
> 
> - edit /config.rktd to contain 
> (lib-search-dirs . (#f "/opt/local/lib”)) 
> 
> Let me know if I misunderstood your situation! 
> 
> John Clements 
> 
> 
> > On May 6, 2021, at 3:54 AM, krs...@gmail.com  wrote: 
> > 
> > 
> > Hi!, 
> > 
> > I am doing: (require taglib) and I get: 
> > > (require taglib) 
> > ; ffi-lib: could not load foreign library 
> > ; path: libtag_c.so.0 
> > ; system error: File not found 
> > ; [,bt for context] 
> > 
> > I am on OpenBSD and that file is at: 
> > /usr/local/lib/libtag_c.so.3.0 
> > 
> > How can I change my search path for C libs to be /usr/local ? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Racket Users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to racket-users...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/b8425f0a-6d45-4954-9e32-df51aa5151cbn%40googlegroups.com.
> >  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> 

Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread krs...@gmail.com
I know it sees my custom dir, I ran this in racket:
> (require setup/dirs)
> (get-lib-search-dirs)
'(#
  #
  #)


On Friday, May 7, 2021 at 8:08:26 AM UTC-4 krs...@gmail.com wrote:

> I'm so close :)
>
> I installed taglib locally to /home/wise/root/lib, so I *have* the file 
> exactly as racket is complaining about:
> /home/wise/root/lib/libtag_c.so.0
>
> I used your config example to edit (as root) /etc/racket/config.rktd
> I added the "lib-search-dirs" line, so it looks like:
> ;; generated by unixstyle-install
> #hash(
>   (doc-dir . "/usr/local/share/doc/racket")
>   (lib-dir . "/usr/local/lib/racket")
>   (share-dir . "/usr/local/share/racket")
>   (include-dir . "/usr/local/include/racket")
>   (bin-dir . "/usr/local/bin")
>   (apps-dir . "/usr/local/share/applications")
>   (man-dir . "/usr/local/man")
>   (absolute-installation? . #t)
>   (build-stamp . "")
>   (doc-search-url . "
> https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html
> ")
>   (catalogs . ("https://download.racket-lang.org/releases/7.9/catalog/
> "))
>   (lib-search-dirs . (#f "/home/wise/root/lib"))
> )
>
> I still get the error:
> Welcome to Racket v7.9 [cs].
>
> > (require taglib)
> ; ffi-lib: could not load foreign library
> ;   path: libtag_c.so.0
> ;   system error: File not found
> ; [,bt for context]
>
> I'm still poking at it, thanks again for the help.
>
> On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:
>
>> Thanks for the help!
>> I was sure that was going to be it but it's not :(
>>
>> This is what is on my system:
>> /usr/local/lib/libtag_c.so.3.0
>>
>> racket is looking for libtag_c.so.0
>>
>> So i'm not sure what to do next.
>>
>> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
>>
>>> It looks to me like you probably need to edit your “config.rktd” file: 
>>>
>>>
>>> https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29
>>>  
>>>
>>> On my machine (macOS using macports), for instance I have do do this for 
>>> every new installation of drracket: 
>>>
>>> - edit /config.rktd to contain 
>>> (lib-search-dirs . (#f "/opt/local/lib”)) 
>>>
>>> Let me know if I misunderstood your situation! 
>>>
>>> John Clements 
>>>
>>>
>>> > On May 6, 2021, at 3:54 AM, krs...@gmail.com  
>>> wrote: 
>>> > 
>>> > 
>>> > Hi!, 
>>> > 
>>> > I am doing: (require taglib) and I get: 
>>> > > (require taglib) 
>>> > ; ffi-lib: could not load foreign library 
>>> > ; path: libtag_c.so.0 
>>> > ; system error: File not found 
>>> > ; [,bt for context] 
>>> > 
>>> > I am on OpenBSD and that file is at: 
>>> > /usr/local/lib/libtag_c.so.3.0 
>>> > 
>>> > How can I change my search path for C libs to be /usr/local ? 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "Racket Users" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to racket-users...@googlegroups.com. 
>>> > To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/racket-users/b8425f0a-6d45-4954-9e32-df51aa5151cbn%40googlegroups.com.
>>>  
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/59a44f94-5931-46cd-ba3b-039c02a47076n%40googlegroups.com.


Re: [racket-users] Tell require where to find C libraries ?

2021-05-07 Thread krs...@gmail.com
I'm so close :)

I installed taglib locally to /home/wise/root/lib, so I *have* the file 
exactly as racket is complaining about:
/home/wise/root/lib/libtag_c.so.0

I used your config example to edit (as root) /etc/racket/config.rktd
I added the "lib-search-dirs" line, so it looks like:
;; generated by unixstyle-install
#hash(
  (doc-dir . "/usr/local/share/doc/racket")
  (lib-dir . "/usr/local/lib/racket")
  (share-dir . "/usr/local/share/racket")
  (include-dir . "/usr/local/include/racket")
  (bin-dir . "/usr/local/bin")
  (apps-dir . "/usr/local/share/applications")
  (man-dir . "/usr/local/man")
  (absolute-installation? . #t)
  (build-stamp . "")
  (doc-search-url . 
"https://download.racket-lang.org/releases/7.9/doc/local-redirect/index.html;)
  (catalogs . 
("https://download.racket-lang.org/releases/7.9/catalog/;))
  (lib-search-dirs . (#f "/home/wise/root/lib"))
)

I still get the error:
Welcome to Racket v7.9 [cs].
> (require taglib)
; ffi-lib: could not load foreign library
;   path: libtag_c.so.0
;   system error: File not found
; [,bt for context]

I'm still poking at it, thanks again for the help.

On Thursday, May 6, 2021 at 11:41:03 PM UTC-4 krs...@gmail.com wrote:

> Thanks for the help!
> I was sure that was going to be it but it's not :(
>
> This is what is on my system:
> /usr/local/lib/libtag_c.so.3.0
>
> racket is looking for libtag_c.so.0
>
> So i'm not sure what to do next.
>
> On Thursday, May 6, 2021 at 7:21:10 PM UTC-4 johnbclements wrote:
>
>> It looks to me like you probably need to edit your “config.rktd” file: 
>>
>>
>> https://docs.racket-lang.org/raco/config-file.html?q=config.rktd#%28idx._%28gentag._67._%28lib._scribblings%2Fraco%2Fraco..scrbl%29%29%29
>>  
>>
>> On my machine (macOS using macports), for instance I have do do this for 
>> every new installation of drracket: 
>>
>> - edit /config.rktd to contain 
>> (lib-search-dirs . (#f "/opt/local/lib”)) 
>>
>> Let me know if I misunderstood your situation! 
>>
>> John Clements 
>>
>>
>> > On May 6, 2021, at 3:54 AM, krs...@gmail.com  wrote: 
>> > 
>> > 
>> > Hi!, 
>> > 
>> > I am doing: (require taglib) and I get: 
>> > > (require taglib) 
>> > ; ffi-lib: could not load foreign library 
>> > ; path: libtag_c.so.0 
>> > ; system error: File not found 
>> > ; [,bt for context] 
>> > 
>> > I am on OpenBSD and that file is at: 
>> > /usr/local/lib/libtag_c.so.3.0 
>> > 
>> > How can I change my search path for C libs to be /usr/local ? 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups "Racket Users" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to racket-users...@googlegroups.com. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/b8425f0a-6d45-4954-9e32-df51aa5151cbn%40googlegroups.com.
>>  
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/713e783e-db5f-4a19-8e4c-d33a6c842b57n%40googlegroups.com.