I created some toy in the C ++ library to quickly create a Qt window from Lisp. I know that common-qt exists, I'm just trying to learn how to use cffi.
I now have 4 attached functions:
- create-application: create QApplication and return a pointer
- create-window: create a QMainWindow and return a poiner
- show: show the window specified as an argument
- exec: Qt exec function
Here is the lisp code that works fine:
(defctype t-app :pointer) (defctype t-window :pointer) (defcfun (create-application "create_application" ) t-app) (defcfun (exec "exec") :void (app t-app)) (defcfun (create-window-aalt "create_window_aalt") t-window) (defcfun (show "show") :void (o t-window)) (defparameter a (create-application)) (defparameter w (create-window-aalt)) (show w) (exec a)
But if I use LET or LET * ... I have a memory error!
(let* ((a (create-application)) (w (create-window-aalt))) (show w) (exec a)) CORRUPTION WARNING in SBCL pid 1312(tid 140737353860992): Memory fault at a556508 (pc=0x7ffff659b7f1, sp=0x7ffff2bbe688) The integrity of this image is possibly compromised. Exiting.
Does anyone know why?
I am using SBCL:
env LD_LIBRARY_PATH=`pwd` \ env LD_PRELOAD=/usr/lib/libQtGui.so.4 \ sbcl --script aalt.lisp
Thanks.
source share