Trouble loading some libraries using CFFI

Discussion of Common Lisp

Trouble loading some libraries using CFFI

Postby virex » Sat Oct 29, 2011 1:58 pm

Dear Lispers,

I seem to have run across a little problem with importing external libraries, which can most easily be seen from the following session:
Code: Select all
CL-USER> (probe-file "./lib/SDL.dll")
#P"c:/Programming/Projects/lisp/BloodTV/lib/SDL.dll"
CL-USER> (CFFI:load-foreign-library *)
#<CFFI:FOREIGN-LIBRARY #xCC375B6>
CL-USER> (probe-file "./lib/SDL_ttf.dll")
#P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll"
CL-USER> (CFFI:load-foreign-library *)
; Evaluation aborted on #<CFFI:LOAD-FOREIGN-LIBRARY-ERROR #xCBEB8FE>.

That last one terminates with the error:
Code: Select all
Unable to load foreign library (LIBRARY-142).
  Error opening shared library c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll : Kan opgegeven module niet vinden. .
   [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]

Backtrace:
  0: (CFFI::FL-ERROR "Unable to load foreign library (~A).~%  ~A" #:LIBRARY-142 "Error opening shared library c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll : Kan opgegeven module niet vinden. .")
      Locals:
        CFFI::CONTROL = "Unable to load foreign library (~A).~%  ~A"
        CFFI::ARGUMENTS = (#:LIBRARY-142 ..))
  1: ((:INTERNAL CFFI::%DO-LOAD CFFI::%DO-LOAD-FOREIGN-LIBRARY) #<CFFI:FOREIGN-LIBRARY #xCC771C6> #:LIBRARY-142 #P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll")
      Locals:
        CFFI::LIB = #<CFFI:FOREIGN-LIBRARY #xCBF7866>
        CFFI::NAME = #:LIBRARY-142
        CFFI::SPEC = #P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll"
  2: (CFFI:LOAD-FOREIGN-LIBRARY #P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll" :SEARCH-PATH NIL)
      Locals:
        CFFI::LIBRARY = #P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll"
        CFFI::SEARCH-PATH = NIL
        #:USE-VALUE = #<RESTART USE-VALUE #x3BCF8AE>
        #:RETRY = #<RESTART CFFI::RETRY #x3BCF886>
        #:G8388 = (#<RESTART CFFI::RETRY #x3BCF886> #<RESTART USE-VALUE #x3BCF8AE>)
        CCL::%RESTARTS% = ((#<RESTART CFFI::RETRY #x3BCF886> #<RESTART USE-VALUE #x3BCF8AE>) ..)))
  3: (CCL::CALL-CHECK-REGS CFFI:LOAD-FOREIGN-LIBRARY #P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll")
      Locals:
        CCL::FN = CFFI:LOAD-FOREIGN-LIBRARY
        CCL::ARGS = (#P"c:/Programming/Projects/lisp/BloodTV/lib/SDL_ttf.dll")
        CCL::OLD-REGS = NIL
  4: (CCL::CHEAP-EVAL (CFFI:LOAD-FOREIGN-LIBRARY *))
      Locals:
        CCL::FORM = (CFFI:LOAD-FOREIGN-LIBRARY *)
        CCL::*NX-SOURCE-NOTE-MAP* = NIL
  5: (SWANK::EVAL-REGION "(CFFI:load-foreign-library *)\n")
      Locals:
        STRING = "(CFFI:load-foreign-library *)\n"
        STREAM = #<STRING-INPUT-STREAM  #xCBF79CE>
        VALUES = NIL
        - = (CFFI:LOAD-FOREIGN-LIBRARY *)
        SWANK::FORM = (CFFI:LOAD-FOREIGN-LIBRARY *)
  6: ((:INTERNAL SWANK::REPL-EVAL))
      Locals:
        STRING = "(CFFI:load-foreign-library *)\n"


Basically I'm stumped. It should be perfectly capable of finding the file, but it doesn't?
virex
 
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm

Re: Trouble loading some libraries using CFFI

Postby Ramarren » Sat Oct 29, 2011 11:11 pm

I'm guessing that the issue is that SDL_ttf depends on Freetype. If you are not going to place the libraries somewhere where the system can find them itself, then you need to specify a pathname to all libraries and their dependencies.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: Trouble loading some libraries using CFFI

Postby virex » Sun Oct 30, 2011 1:18 pm

So I should load the Freetype library first?
virex
 
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm

Re: Trouble loading some libraries using CFFI

Postby nuntius » Mon Oct 31, 2011 6:41 pm

Based on your first code snippet, it appears that PROBE-FILE is incorrectly returning an invalid path.

Which implementation is this? I'd try posting that directly to one of their support lists. It may be fixed in a newer version, or it may be a good bug report.
User avatar
nuntius
 
Posts: 498
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA

Re: Trouble loading some libraries using CFFI

Postby virex » Tue Nov 01, 2011 11:56 am

The behavior is the same under CCL 1.6 (the version I posted) and the version of SBCL I have (0.9.8.1? Most recent stable windows build as of June, IIRC). However, Ramarren seems to have nailed it, I need to load libfreetype-6.dll before loading sdl-ttf.dll. Now I just need to figure out in what order to load all the other libraries and I'm set :)
virex
 
Posts: 17
Joined: Fri Oct 28, 2011 3:41 pm


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot], mzgcz and 4 guests