bvarga / delphizmq

0MQ Delphi binding
GNU Lesser General Public License v3.0
137 stars 63 forks source link

Missing compilation conditionals #13

Closed cpicanco closed 9 years ago

cpicanco commented 9 years ago

Hi everyone,

Is there any chance I get some help to fork this binding to use it with linux and lazarus?

Best Rafael

bvarga commented 9 years ago

Hello,

What have you tried? try running the tests, there's a project file in the tests folder.

regards Balazs

cpicanco commented 9 years ago

I will try again and will document the process this time. :)

cpicanco commented 9 years ago

The current version of the binding should work with fpc 2.6.0, but i will give a try with the 2.6.4.

OS: Crunchbang 11 (rip) / debian stable
zmq_version = 2.2.0 -> [zeromq-2.2.0.tar.gz](http://download.zeromq.org/)
Lazarus 1.2.6
Free Pascal Compiler version 2.6.4 [2014/04/20] for x86_64

1) clone the repository

git clone https://github.com/cpicanco/delphizmq.git

2) open fpctests.lpi

3) undefine zmq3 in zmq.inc:

//{$define zmq3}

{$ifdef fpc}
  {$packset 1}
{$endif}                    

4) Trying to compile "out of the box" stucks in some errors with zmqapi.pas:

/home/rafael/git/delphizmq/zmqapi.pas(2618,15) Error: Identifier not found "zmq_proxy"
/home/rafael/git/delphizmq/zmqapi.pas(2698,27) Error: Identifier not found "GenerateConsoleCtrlEvent"
/home/rafael/git/delphizmq/zmqapi.pas(2698,41) Error: Identifier not found "CTRL_C_EVENT"
/home/rafael/git/delphizmq/zmqapi.pas(2799) Fatal: There were 3 errors compiling module, stopping

zmq_proxy from zmq.pas depends on a defined zmq3 in zmq.inc

{$ifdef zmq3}
{*  Built-in message proxy (3-way) *}
function zmq_proxy( frontend, backend, capture: Pointer ): Integer; cdecl; external libzmq;

{$endif} 

GenerateConsoleCtrlEvent(CTRL_C_EVENT... is windows only, isn't it?. Honestly I don't know if it is included in lazarus, but I found a thread with people talking about it.

What should I do??

cpicanco commented 9 years ago

So... from this report i think zmq_proxy is not available at all in 2.2.0. http://upstream.rosalinux.ru/pkgdiff_reports/zeromq/2.2.0_to_3.2.2/changes_report.html

So, I think I should restrict it to the zmq3.

bvarga commented 9 years ago

yeap, zmq_proxy is not available in 2.2, a conditional directive is missing there.

you can omit ZMQTerminate too, it's just for generating a Ctrl+C signal, not crutial.

cpicanco commented 9 years ago

Thank you man!!

I have made this two small changes that I think could be a pull request. What do you think??

zmqapi.pas

procedure ZMQTerminate;
begin
  {$ifndef UNIX}
  GenerateConsoleCtrlEvent( CTRL_C_EVENT, 0 );
  {$endif}
end; 

and

procedure ZMQProxy( frontend, backend, capture: TZMQSocket );
var
  p: Pointer;
begin
  if capture <> nil then
    p := capture.SocketPtr
  else
    p := nil;

  {$ifdef zmq3}
  if zmq_proxy( frontend.SocketPtr, backend.SocketPtr, p ) <> -1 then
    raise EZMQException.Create( 'Proxy does not return -1' );
  {$endif}

  //raise EZMQException.Create;
end;   

I think this is good...

zeromq-debian

bvarga commented 9 years ago

thanks

cpicanco commented 9 years ago

For instance, I was able to run zmq 3.5 as well, well done @bvarga !!

bvarga commented 9 years ago

:thumbsup: