Hot questions for Using ZeroMQ in common lisp

Question:

I am new to Lisp and am trying to learn. In particular, I am trying to use the ZeroMQ library to make a distributed system. This is my exploratory code

;;hwserver.lisp
(defun main()
  ;; prepare contexts
  (zmq:with-context (context)
    (zmq:with-socket (socket context zmq:rep)
      (zmq:bind socket "tcp://*5555")

      (loop
     (let ((request (make-instance 'zmq:msg)))

       ;; wait for next request from client
       (zmq:recv socket request)
       (print "received request: [~A]~%"
            (zmq:msg-data-as-string request))

       ;;do some work
       (sleep 1)

       ;;send reply back to client
       (let ((reply (make-instance 'zmq:msg :data "Hello World")))
         (zmq:send socket reply))))))
  (sb-ext:exit))

In the REPL, I run the following commands

(ql:quickload "zeromq")
(load "hwserver.lisp")

And then I get the following warning.

; 
; caught WARNING:
;   undefined variable: ZEROMQ:REP
; 
; compilation unit finished
;   Undefined variable:
;     ZEROMQ:REP
;   caught 1 WARNING condition

Though zmq:rep is exported from the zeromq package.

And if I ignore the warning try to run (main), I get the following error

The variable ZEROMQ:REP is unbound.
   [Condition of type UNBOUND-VARIABLE]

Restarts:
 0: [RETRY] Retry SLIME REPL evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {10039B0003}>)

Backtrace:
  ;; backtrace omitted for being uninteresting here

What am I doing wrong here?


Answer:

This line

(zmq:with-socket (socket context zmq:rep)

creates this error

The variable ZEROMQ:REP is unbound.

Means: it is a variable and it has no value. It does not matter if the symbol is exported or not.

To me it looks like the code expects a keyword symbol :rep as a socket type descriptor instead of your zmq:rep.

Another case of a bad macro not checking the types it expects.

Question:

Has anyone gotten ZeroMQ working with LISP in Windows?

I'm using LispBox 0.7

I have installed ZeroMQ.

  1. (ql:quickload "zeromq")
Unable to load foreign library (ZEROMQ).
Error opening shared library libzmq.dll: The specified module could not be found.
     [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]
  1. Add the libzmq-v120-mt-gd-4_0_4.dll dll to the lispbox folder,edit it's name to libzmq.dll andcall (ql:quickload "zeromq") again.
Unable to load foreign library (ZEROMQ).
Error opening shared library libzmq.dll: %1 is not a valid Win32 application.
      [Condition of type CFFI:LOAD-FOREIGN-LIBRARY-ERROR]

Any idea how to get this up and running?


Answer:

Finally found the answer.

I was using the wrong library. Switching to 64 bit version fixed this.