2 # ABSTRACT: find and install 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.3> is installed in a shared directory. In
13 short, modules that need libzmq can depend on this module to make sure that it
14 is available, or use it independently as a way to install zeromq.
21 my $version = version->parse(Alien::ZMQ::lib_version);
22 my $lib_dir = Alien::ZMQ::lib_dir;
24 print "zeromq $version is installed at $lib_dir\n";
28 These options to F<Build.PL> affect the installation of this module.
32 =item --zmq-skip-probe
34 By default, libzmq is not compiled and installed if it is detected to already
35 be on the system. Use this to skip those checks and always install libzmq.
39 Pass extra flags to the compiler when probing for an existing installation of
40 libzmq. You can use this, along with L</--zmq-libs>, to help the probing
41 function locate libzmq if it is installed in an unexpected place. For
42 example, if your libzmq is installed at F</opt/zeromq>, you can do something
45 perl Build.PL --zmq-cflags="-I/opt/zeromq/include" \
46 --zmq-libs="-L/opt/zeromq/lib -lzmq"
48 These flags are only used by the probing function to locate libzmq; they will
49 not be used when compiling libzmq from source (if it needs to be). To affect
50 the compiling of libzmq, using the L</--zmq-config> flag instead.
52 A better alternative to using L</--zmq-cflags> and L</--zmq-libs> is to help
53 the L<pkg-config> program find your libzmq by using the C<PKG_CONFIG_PATH>
54 environment variable. Of course, this method requires that you have the
55 L<pkg-config> program installed. Here's an example:
58 PKG_CONFIG_PATH=/opt/zeromq/lib/pkgconfig ./Build
62 Pass extra flags to the linker when probing for an existing installation of
63 libzmq. You can use this, along with L</--zmq-cflags>, to help the probing
64 function locate libzmq if it is installed in an unexpected place. Like
65 L</--zmq-cflags>, these flags are only used by the probing function to locate
70 Pass extra flags to the libzmq F<configure> script. You may want to consider
71 passing either C<--with-pgm> or C<--with-system-pgm> if you need support for
72 PGM; this is not enabled by default because it is not supported by every
79 Probing is only done during the installation of this module, so if you are
80 using a system-installed version of libzmq and you uninstall or upgrade it,
81 you will also need to reinstall L<Alien::ZMQ>.
83 If S<libzmq-2.x> is found on the system, L<Alien::ZMQ> will use it. There are
84 a few incompatibilities between S<libzmq-2.x> and S<libzmq-3.x>, so your
85 program may want to use the L</lib_version> method to check which version of
90 MSWin32 is not yet supported, but cygwin works.
96 =item * L<GitHub project|https://github.com/chazmcgarvey/p5-Alien-ZMQ>
98 =item * L<ZMQ> - good perl bindings for zeromq
100 =item * L<ZeroMQ|http://www.zeromq.org/> - official libzmq website
104 =head1 ACKNOWLEDGEMENTS
106 The design and implementation of this module were influenced by other L<Alien>
107 modules, including L<Alien::GMP> and L<Alien::Tidyp>.
111 Get the version number of libzmq as a v-string (version string), according to
112 the F<zmq.h> header file.
120 Get the version number of libzmq as a v-string
(version string
), according to
121 the F
<libzmq
.so
> file
.
129 Get the directory containing the F
<zmq
.h
> header file
.
137 Get the directory containing the F
<libzmq
.so
> file
.
145 Get the C compiler flags required to compile a program that uses libzmq
. This
146 is a shortcut
for constructing a C
<-I
> flag using L
</inc_dir
>. In
scalar
147 context
, the flags are quoted using L
<String
::ShellQuote
> and returned as
156 "-I" . shell_quote
(inc_dir
);
162 Get the linker flags required to
link a program against libzmq
. This
is
163 a shortcut
for constructing a C
<-L
> flag using L
</lib_dir
>, plus C
<-lzmq
>. In
164 scalar context
, the flags are quoted using L
<String
::ShellQuote
> and returned
167 On some platforms
, you may also want to add the library path to your
168 executable
or library as a runtime path
; this
is usually done by passing
169 C
<-rpath
> to the linker
. Something like this could work
:
171 my @flags = (Alien
::ZMQ
::libs
, "-Wl,-rpath=" . Alien
::ZMQ
::lib_dir
);
173 This will allow your program to find libzmq
, even
if it
is installed
in
174 a non-standard location
, but some systems don
't have this C<RPATH> mechanism.
180 "-L" . lib_dir, "-lzmq";
182 "-L" . shell_quote(lib_dir) . " -lzmq";