40ants / lisp-project-of-the-day

Here I'll post notes about Quicklisp projects. Also I publish them on Twitter account svetlyak40wt.
http://40ants.com/lisp-project-of-the-day/
BSD 2-Clause "Simplified" License
51 stars 6 forks source link

cl-ncurses #2

Open vindarel opened 4 years ago

vindarel commented 4 years ago

Hello!

As a blog comment, here's my complain: I was excited, thanks for the snippet, but failed to run the ncurses example :(

(ql:quickload :cl-ncurses)

(defpackage :curse
  (:use :cl
        :cl-ncurses)
  (:shadowing-import-from :cl-ncurses
                          :timeout))

(in-package :curse)

(defun main (&rest argv)
  "This example is based on:
   https://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html"
  (declare (ignorable argv))
  (initscr)
  (start-color)
  (init-pair 1
             color_red
             color_black)

…
sbcl --load ncurses.lisp

=>

; Loading "cl-ncurses"

; 
; caught STYLE-WARNING:
;   Undefined alien: "stdscr"
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition
While evaluating the form starting at line 71, column 0
  of #P"/home/vince/bacasable/bacalisp/ncurses.lisp":

debugger invoked on a SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR in thread
#<THREAD "main thread" RUNNING {10005E85B3}>:
  The alien function "initscr" is undefined.

I installed ncurses-dev, alias libncurses5-dev libncursesw5-dev, to no avail. Not searching longer :]

ps: if you want blog comments, I like blog comments linked to Github with Uterances: https://utteranc.es/

pps:

Full examples are available here: --no link--

svetlyak40wt commented 4 years ago

Which OS do you have?

And which libraries were loaded by UFFI?

I have OSX and for me it shows:

POFTHEDAY> uffi::*loaded-libraries*
("/usr/lib/libncurses.dylib")

Which is a symlink to /usr/lib/libncurses.5.4.dylib

vindarel commented 4 years ago

not Debian actually but Ubuntu, and *loaded-libraries* returns NIL. I'll try to install more ncurses[-dev] dependencies.

svetlyak40wt commented 4 years ago

I found that cl-ncurses has these paths built in:

(defvar *ncurses-search-paths*
  #-win32'("/usr/local/lib64/" "/usr/local/lib/" "/lib64/" "/lib/" "/usr/lib64/" "/usr/lib/")
  #+win32'("/users/jacob/src/pdc31dll/"))

But on Ubuntu Bionic libncurses lies here:

/lib/x86_64-linux-gnu/libncurses.so.5.9

Add this line before (initscr) in the main function:

(uffi:load-foreign-library "/lib/x86_64-linux-gnu/libncurses.so.5.9"
    :module "cl-ncurses")
svetlyak40wt commented 4 years ago

BTW, thank you, @vindarel! I've added comments to the site!

vindarel commented 4 years ago

Great*2! it works for me.