(define impc:ti:bind-dylib
(lambda (library lib-paths)
(let ((dylib-pair
(let loop ((paths lib-paths))
(if (null? paths)
#f
(or (impc:ti:search-for-dylib (car paths))
(loop (cdr paths)))))))
(if dylib-pair
(begin
(eval (list 'define library (car dylib-pair))
(interaction-environment))
(set! *impc:aot:current-load-dylib-info*
(cons library (cdr dylib-pair)))
(impc:aot:add-win-link-library (cdr dylib-pair))
(impc:compiler:print-dylib-loading-details-to-log (cdr dylib-pair))
#t)
(begin
(print-with-colors *impc:compiler:pretty-print-error-color* 'default #t
(print "Error"))
(print ": could not find ")
(print-with-colors *impc:compiler:pretty-print-type-color* 'default #t (print library))
(print " dynamic library\n")
(error ""))))))