macos 如何在 OSX 上为 ZeroMQ 编译 jzmq?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3522248/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I compile jzmq for ZeroMQ on OSX?
提问by Joshua
Trying to follow the directions from: http://github.com/zeromq/jzmq
尝试按照以下说明操作:http: //github.com/zeromq/jzmq
I installed pkg-config using Homebrew and then I run the following commands: ./autogen.sh ./configure
我使用 Homebrew 安装了 pkg-config,然后运行以下命令:./autogen.sh ./configure
The configure fails with:
配置失败:
checking how to hardcode library paths into programs... immediate ./configure: line 15263: syntax error near unexpected token `newline' ./configure: line 15263: ` PKG_CHECK_MODULES('
采纳答案by SangWoo
I made a simple list about jzmq building for MacOS.
我为 MacOS 制作了一个关于 jzmq 构建的简单列表。
Install brew
Install tools for jzmq building
brew install autoconf brew install automake brew install libtool brew install pkg-config brew install [email protected]
Download jzmq source
https://github.com/zeromq/jzmqsource download to ~/somewhere/jzmq
Add symbolic link to /usr/local/include
cd /usr/local/include ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/include/zmq.h ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/include/zmq_utils.h
Add symbolic linke to /usr/local/lib
cd /usr/local/lib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libzmq.3.dylib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libzmq.a ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libmq.dylib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/pkgconfig/
Build jzmq-jni
cd ~/somewhere/jzmq cd jzmq-jni ./autogen.sh ./configure make make install
Add option to VM options
安装 brew
安装 jzmq 构建工具
brew install autoconf brew install automake brew install libtool brew install pkg-config brew install [email protected]
下载jzmq源码
https://github.com/zeromq/jzmq源码下载到~/somewhere/jzmq
将符号链接添加到 /usr/local/include
cd /usr/local/include ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/include/zmq.h ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/include/zmq_utils.h
将符号链接添加到 /usr/local/lib
cd /usr/local/lib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libzmq.3.dylib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libzmq.a ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/libmq.dylib ln -s /usr/local/Cellar/zeromq\@3.2/3.2.5/lib/pkgconfig/
构建 jzmq-jni
cd ~/somewhere/jzmq cd jzmq-jni ./autogen.sh ./configure make make install
向 VM 选项添加选项
VM options -Djava.library.path=/usr/local/lib
虚拟机选项 -Djava.library.path=/usr/local/lib
回答by Beekhof
A better solution is:
更好的解决方案是:
eval `brew --config | grep HOMEBREW_PREFIX | sed 's/: /=/'`
sudo bash -c 'echo '$HOMEBREW_PREFIX/share/aclocal' >> `aclocal --print-ac-dir`/dirlist'
This will allow the version of aclocal that ships with OSX to find anymacros installed by homebrew packages.
这将允许aclocal会的版本附带的OSX找到任何通过自制软件的软件包安装宏。
回答by Phil Cal?ado
With homebrew, the key is the warning message:
使用自制软件,关键是警告信息:
~/code/foss/java/jzmq$ brew install pkg-config
==> Downloading http://pkg-config.freedesktop.org/releases/pkg-config-0.25.tar.gz
==> ./configure --disable-debug --prefix=/usr/local/Cellar/pkg-config/0.25 --with-pc-path=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig
==> make install
Warning: m4 macros were installed to "share/aclocal".
Homebrew does not append "/usr/local/share/aclocal"
to "/usr/share/aclocal/dirlist". If an autoconf script you use
requires these m4 macros, you'll need to add this path manually.
==> Summary
/usr/local/Cellar/pkg-config/0.25: 8 files, 232K, built in 19 seconds
If you look at /usr/local/Cellar/pkg-config/0.25/share/aclocal/, you will see:
如果您查看 /usr/local/Cellar/pkg-config/0.25/share/aclocal/,您将看到:
$ ls /usr/local/Cellar/pkg-config/0.25/share/aclocal/
pkg.m4
You need to append /usr/local/Cellar/pkg-config/0.25/share/aclocal/ to /usr/share/aclocal/dirlist,like this:
您需要将 /usr/local/Cellar/pkg-config/0.25/share/aclocal/ 附加到 /usr/share/aclocal/dirlist,如下所示:
$ cat /usr/share/aclocal/dirlist
/usr/local/share/aclocal
/usr/local/Cellar/pkg-config/0.25/share/aclocal/
And then re-run autogen and the other steps.
然后重新运行 autogen 和其他步骤。
回答by caljunior
From the zeromq mailing list:
从 zeromq邮件列表:
Building 0MQ from the development trunk on a UNIX style OS (Linux, OS X) requires that pkg-config (http://pkg-config.freedesktop.org/wiki/) be installed. A regular source build of 0MQ does not require pkg-config. On Mac OS X, pkg-config does not come with the system, so when you try to do ./configure you may see errors like:
./configure: line 23913: syntax error near unexpected token `GLIB,' ./configure: line 23913: `PKG_CHECK_MODULES(GLIB, glib-2.0 gthread-2.0)'
To resolve this, you need to install the latest pkg-config:
tar xzf pkg-config-0.25.tar.gz cd pkg-config-0.25 ./configure --prefix=/usr/local/pkg-config-0.25 --datarootdir=/usr/share make sudo make install
Then you will need to put
/usr/local/pkg-config-0.25/bin
on your $PATH. It is important to include the"--datarootdir=/usr/share"
option, which will install the pkg.m4 file in/usr/share/aclocal
, where aclocal will be able to find it.Then you can build 0MQ:
cd zeromq2 ./autogen.sh # must do this again after installing pkg-config ./configure # add other options here make sudo make install
在 UNIX 风格的操作系统(Linux、OS X)上从开发主干构建 0MQ 需要安装pkg-config(http://pkg-config.freedesktop.org/wiki/)。0MQ 的常规源代码构建不需要 pkg-config。在 Mac OS X 上,系统不附带 pkg-config,因此当您尝试执行 ./configure 时,您可能会看到如下错误:
./configure: line 23913: syntax error near unexpected token `GLIB,' ./configure: line 23913: `PKG_CHECK_MODULES(GLIB, glib-2.0 gthread-2.0)'
要解决此问题,您需要安装最新的 pkg-config:
tar xzf pkg-config-0.25.tar.gz cd pkg-config-0.25 ./configure --prefix=/usr/local/pkg-config-0.25 --datarootdir=/usr/share make sudo make install
然后你需要穿上
/usr/local/pkg-config-0.25/bin
你的 $PATH。包含该"--datarootdir=/usr/share"
选项很重要,该 选项将在 中安装 pkg.m4 文件/usr/share/aclocal
,aclocal 将能够在其中找到它。然后你可以构建0MQ:
cd zeromq2 ./autogen.sh # must do this again after installing pkg-config ./configure # add other options here make sudo make install
Edited to reflect latest pkg-config version (0.25).
编辑以反映最新的 pkg-config 版本 (0.25)。
回答by user503667
I came here with the same question, and I don't feel this is answered. I also installed ZeroMQ and pkg-config via Homebrew. /usr/local/share/aclocal/pkg.m4 exists and comes from pkg-config 0.25. It seems that Homebrew has satisfied the requirements listed but it still fails.
我带着同样的问题来到这里,我觉得这没有得到解答。我还通过 Homebrew 安装了 ZeroMQ 和 pkg-config。/usr/local/share/aclocal/pkg.m4 存在并且来自 pkg-config 0.25。Homebrew 似乎满足了列出的要求,但它仍然失败。
回答by Ilya Sterin
Trying to compile jzmqon Mac OS X, proved to be a bit of a headache. I followed the instructions above. I was still getting following error
尝试在 Mac OS X 上编译jzmq,结果证明有点头疼。我按照上面的说明进行操作。我仍然收到以下错误
syntax error near unexpected token `PKG_CHECK_MODULES
意外标记附近的语法错误`PKG_CHECK_MODULES
The instructions above tell you to copy the pkgk.m4file into /usr/share/aclocal, but your directory might be different. Basically you need the dir that automakesearches for macro definitions.
上面的说明告诉您将pkgk.m4文件复制到/usr/share/aclocal,但您的目录可能不同。基本上,您需要automake搜索宏定义的目录。
The _PKG_CHECK_MODULES_ macro is defined in the pkg.m4file. This file must be installed in the appropriate directory, which is searched by automake. Somehow automake is installed twice on my OS X, one in /usrand another in /Developer/usr. Make sure you know which one it's using. Just do which automake. If yours in is /Developer/usr, then copy the pkg.m4file to /Developer/usr/share/aclocal.
_PKG_CHECK_MODULES_ 宏在pkg.m4文件中定义。该文件必须安装在适当的目录中,由automake搜索。不知何故,automake 在我的 OS X 上安装了两次,一个在/usr,另一个在/Developer/usr。确保您知道它使用的是哪一种。只需执行which automake。如果您在/Developer/usr 中,则将pkg.m4文件复制到/Developer/usr/share/aclocal。
回答by George
For me, the problem was that I didn't have pkg-config installed.
对我来说,问题是我没有安装 pkg-config。
回答by Rex
On Osx Mountain Lion I don't have the dirlist file as Phil Cal?ado said, but a simple symlink from /usr/local/Cellar/pkg-config/[version]/share/aclocal/pkg.m4
to /usr/share/aclocal
made the trick and now jzmq build fine.
在 Osx Mountain Lion 上,我没有 Phil Cal?ado 所说的 dirlist 文件,但是来自/usr/local/Cellar/pkg-config/[version]/share/aclocal/pkg.m4
to 的一个简单符号链接就/usr/share/aclocal
成功了,现在 jzmq 构建得很好。