From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: gustav Newsgroups: gmane.lisp.guile.user Subject: Re: C module problem Date: Mon, 28 Feb 2011 10:35:04 -0500 (EST) Message-ID: <20110228153504.8A18E164085@perth.ovpit.indiana.edu> References: <440851.45861.qm@web37908.mail.mud.yahoo.com> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1298907343 2243 80.91.229.12 (28 Feb 2011 15:35:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 28 Feb 2011 15:35:43 +0000 (UTC) Cc: guile-user@gnu.org To: spk121@yahoo.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Feb 28 16:35:37 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Pu58J-0001cn-Vg for guile-user@m.gmane.org; Mon, 28 Feb 2011 16:35:36 +0100 Original-Received: from localhost ([127.0.0.1]:47208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu58J-0006JO-G6 for guile-user@m.gmane.org; Mon, 28 Feb 2011 10:35:35 -0500 Original-Received: from [140.186.70.92] (port=45769 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pu581-0006J0-PH for guile-user@gnu.org; Mon, 28 Feb 2011 10:35:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pu580-00043v-KX for guile-user@gnu.org; Mon, 28 Feb 2011 10:35:17 -0500 Original-Received: from perth.ovpit.indiana.edu ([129.79.207.210]:37637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pu580-00042y-HS for guile-user@gnu.org; Mon, 28 Feb 2011 10:35:16 -0500 Original-Received: from Crawley (iub-vpn-192-176.noc.indiana.edu [156.56.192.176]) by perth.ovpit.indiana.edu (Postfix) with ESMTP id 8A18E164085; Mon, 28 Feb 2011 10:35:04 -0500 (EST) In-reply-to: <440851.45861.qm@web37908.mail.mud.yahoo.com> (message from Mike Gran on Mon, 28 Feb 2011 06:54:04 -0800 (PST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 129.79.207.210 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8472 Archived-At: > 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