2 # ABSTRACT: finding and installing libzmq, the core zeromq library
7 use String
::ShellQuote qw
/shell_quote/;
11 Upon installation, the target system is probed for the presence of libzmq. If
12 it is not found, B<libzmq 3.2.2> is installed in a shared directory. In
13 short, modules that need libzmq can depend on this module to make sure that it
16 This module is still B<EXPERIMENTAL>. In particular, I'm still pondering on
17 how S<libzmq-2.x> should be handled. Currently, if S<libzmq-2.x> is found on
18 the system, L<Alien::ZMQ> will use it, but there is no way to install
19 S<libzmq-2.x> with L<Alien::ZMQ>. I'm not sure what the most useful behavior
20 with regards to S<libzmq-2.x> is, so please talk to me if you have any ideas.
27 my $version = version->parse(Alien::ZMQ::lib_version);
28 my $lib_dir = Alien::ZMQ::lib_dir;
30 print "zeromq $version is installed at $lib_dir\n";
34 These options to F<Build.PL> affect the installation of this module.
38 =item --zmq-skip-probe
40 By default, libzmq is not compiled and installed if it is detected to already
41 be on the system. Use this to skip those checks and always install libzmq.
45 Pass extra flags to the compiler when probing for an existing installation of
46 libzmq. You can use this, along with L</--zmq-libs>, to help the probing
47 function locate libzmq if it is installed in an unexpected place. For
48 example, if your libzmq is installed at F</opt/zeromq>, you can do something
51 perl Build.PL --zmq-cflags="-I/opt/zeromq/include" \
52 --zmq-libs="-L/opt/zeromq/lib -lzmq"
54 These flags are only used by the probing function to locate libzmq; they will
55 not be used when compiling libzmq from source (if it needs to be). To affect
56 the compiling of libzmq, using the L</--zmq-config> flag instead.
58 A better alternative to using L</--zmq-cflags> and L</--zmq-libs> is to help
59 the L<pkg-config(1)> program find your libzmq by using the C<PKG_CONFIG_PATH>
60 environment variable. Of course, this method requires that you have the
61 L<pkg-config(1)> program installed. Here's an example:
64 PKG_CONFIG_PATH=/opt/zeromq/lib/pkgconfig ./Build
68 Pass extra flags to the linker when probing for an existing installation of
69 libzmq. You can use this, along with L</--zmq-cflags>, to help the probing
70 function locate libzmq if it is installed in an unexpected place. Like
71 L</--zmq-cflags>, these flags are only used by the probing function to locate
76 Pass extra flags to the libzmq F<configure> script. You may want to consider
77 passing either C<--with-pgm> or C<--with-system-pgm> if you need support for
78 PGM; this is not enabled by default because it is not supported by every
85 Probing is only done during the installation of this module, so if you are
86 using a system-installed version of libzmq and you uninstall or upgrade it,
87 you will also need to reinstall L<Alien::ZMQ>.
91 MSWin32 is not yet supported, but cygwin works.
97 =item * L<GitHub project|https://github.com/chazmcgarvey/p5-Alien-ZMQ>
99 =item * L<ZMQ> - good perl bindings for zeromq
101 =item * L<ZeroMQ|http://www.zeromq.org/> - official libzmq website
105 =head1 ACKNOWLEDGEMENTS
107 The design and implementation of this module were influenced by other L<Alien>
108 modules, including L<Alien::GMP> and L<Alien::Tidyp>.
112 Get the version number of libzmq as a v-string (version string), according to
113 the F<zmq.h> header file.
121 Get the version number of libzmq as a v-string
(version string
), according to
122 the F
<libzmq
.so
> file
.
130 Get the directory containing the F
<zmq
.h
> header file
.
138 Get the directory containing the F
<libzmq
.so
> file
.
146 Get the C compiler flags required to compile a program that uses libzmq
. This
147 is a shortcut
for constructing a C
<-I
> flag using L
</inc_dir
>. In
scalar
148 context
, the flags are quoted using L
<String
::ShellQuote
> and returned as
157 "-I" . shell_quote
(inc_dir
);
163 Get the linker flags required to
link a program against libzmq
. This
is
164 a shortcut
for constructing a C
<-L
> flag using L
</lib_dir
>, plus C
<-lzmq
>. In
165 scalar context
, the flags are quoted using L
<String
::ShellQuote
> and returned
168 On some platforms
, you may also want to add the library path to your
169 executable
or library as a runtime path
; this
is usually done by passing
170 C
<-rpath
> to the linker
. Something like this could work
:
172 my @flags = (Alien
::ZMQ
::libs
, "-Wl,-rpath=" . Alien
::ZMQ
::lib_dir
);
174 This will allow your program to find libzmq
, even
if it
is installed
in
175 a non-standard location
, but some systems don
't have this C<RPATH> mechanism.
181 "-L" . lib_dir, "-lzmq";
183 "-L" . shell_quote(lib_dir) . " -lzmq";