> I am trying to write a simple C module for Guile (for the learning > experience) and I have run into a cryptic error. I have compiled > `sdl-guile.c' to `sdl-guile.so' with the following command. > > gcc -shared -o sdl-guile.so -fPIC sdl-guile.c `guile-config compile` > `sdl-config > --cflags` > > I then run `guile' and evaluate > (load-extension "./sdl-guile.so" "init_module") and get the > following > output. > > ERROR: In procedure load-extension: > ERROR: In procedure dynamic-link: file: "./sdl-guile.so", message: > "file not found"
I've seen similar errors in the past, exactly in the same context. They mostly had to do with Guile unable to find the file, because you *must* give it a full path. The "load-extension" function does not seem to understand "./", or other similar UNIXy tricks, e.g., "~/", "../", etc. Here is, for example, what I had to do to make it load in one case: (define libguile_gsl "/home/gustav/src/Forms/lib/libguile_gsl") (define libguile_gsl_file (string-join (list libguile_gsl "dll") "." 'infix)) (if (access? libguile_gsl_file (logior R_OK X_OK)) (load-extension libguile_gsl "init_gsl")) Another, more universal example: (define SYSTEM (utsname:sysname (uname))) (cond ((equal? SYSTEM "Linux") (define DLIB_EXT ".so") (define LIB "/fusion/gpfs/project/photonic/lib/Forms")) ((equal? SYSTEM "CYGWIN_NT-6.0-WOW64") (define DLIB_EXT ".dll") (define LIB (string-append (getenv "HOME") "/src/Forms/lib"))) (#t (define DLIB_EXT "") (define LIB ""))) ... (load-extension (string-append LIB "/harmonic" DLIB_EXT) "init_signal_lambdas") (load-extension (string-append LIB "/drude" DLIB_EXT) "init_e_lambda") Hope this helps, Cheers, Zdzislaw (Gustav) Meglicki, Office of the Vice President for Information Technology, Indiana University, 601 E. Kirkwood Ave., Room 116, Bloomington, IN 47405-1223, USA, http://perth.ovpit.indiana.edu/gustav, Ph: 812-856-5597 (o), 812-345-3284 (m), Fax: 812-855-3310/812-856-3147, Skype: zdzislaw.meglicki