librdkafka 0.7 编译失败解决办法
2013-07-16 10:38
1451 查看
Kafka MQ是一个高吞吐量分布式消息系统,是由LinkedIn开源的消息中间件。原生的Kafka是由Java实现的,当需要应用到C/C++环境时,需要C/C++的接口。librdkafka是一个C语言的Kafka API,也是Kafka官网推荐使用的C语言API,作者是Magnus Edenhill。这里使用的版本是librdkafka 0.7。
昨天在Linux上编译librdkafka,发现编译失败。make all,出现如下提示:
在网上搜了好久,都找不到解决办法。
今天,请教了一下同事,解决办法其实很简单,把gcc的选项 -Werror 去掉就可以了,在 Makefile 中直接修改。
man gcc,-Werror 的含义是 Make all warnings into errors,其实上面的 “warnings being treated as errors” 已经说得很明显,只是自己很少用 make,所以脑子一时转不过来,以为只要make 加上 -i 选项去忽略 warning即可,殊不知,应当是在 gcc 的选项中去忽略 warning ,感觉自己弱爆了。= =
下午,又遇到一个问题,在example中make ,出现undefined reference to `__sync_sub_and_fetch_4',google 之说是GCC的版本太老,最简单的办法就是升级一下。当然不升级也可以,在命令行中输入arch。假如输出是"i686",那么,在 librdkafka 目录下的 Makefile 的 CFLAGS 中加上选项 -march=i686,重新make all 和 make install。应该就可以解决这个问题了。
GCC 的手册中,对 -march 的作用说明如下。
-march=name
This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code.
最后,如果你跟我一样不幸,又蹦出一个这样的问题 undefined reference to `TAILQ_FIRST',那么是你的 sys/queue.h 太老了。当然,最简单的就是升级一下系统了,这个系统文件太老了。
如果不方便升级系统,那可以在 http://linux.die.net/include/sys/queue.h 下载 queue.h,放在 librdkafka目录下。然后把所有#include <sys/queue.h>替换为#include "queue.h"。再次重新make all 和 make install。
昨天在Linux上编译librdkafka,发现编译失败。make all,出现如下提示:
cc -MD -MP -O2 -Wall -Werror -Wfloat-equal -Wpointer-arith -fPIC -I. -g -c rdkafka.c cc1: warnings being treated as errors rdkafka.c: In function 'rd_kafka_q_pop': rdkafka.c:551: warning: implicit declaration of function 'TAILQ_FIRST' rdkafka.c:551: warning: assignment makes pointer from integer without a cast make: *** [rdkafka.o] Error 1
在网上搜了好久,都找不到解决办法。
今天,请教了一下同事,解决办法其实很简单,把gcc的选项 -Werror 去掉就可以了,在 Makefile 中直接修改。
man gcc,-Werror 的含义是 Make all warnings into errors,其实上面的 “warnings being treated as errors” 已经说得很明显,只是自己很少用 make,所以脑子一时转不过来,以为只要make 加上 -i 选项去忽略 warning即可,殊不知,应当是在 gcc 的选项中去忽略 warning ,感觉自己弱爆了。= =
下午,又遇到一个问题,在example中make ,出现undefined reference to `__sync_sub_and_fetch_4',google 之说是GCC的版本太老,最简单的办法就是升级一下。当然不升级也可以,在命令行中输入arch。假如输出是"i686",那么,在 librdkafka 目录下的 Makefile 的 CFLAGS 中加上选项 -march=i686,重新make all 和 make install。应该就可以解决这个问题了。
GCC 的手册中,对 -march 的作用说明如下。
-march=name
This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code.
最后,如果你跟我一样不幸,又蹦出一个这样的问题 undefined reference to `TAILQ_FIRST',那么是你的 sys/queue.h 太老了。当然,最简单的就是升级一下系统了,这个系统文件太老了。
如果不方便升级系统,那可以在 http://linux.die.net/include/sys/queue.h 下载 queue.h,放在 librdkafka目录下。然后把所有#include <sys/queue.h>替换为#include "queue.h"。再次重新make all 和 make install。
相关文章推荐
- 关于librdkafka编译错误问题解决
- 【转】NDK编译可执行文件在Android L中运行显示error: only position independent executables (PIE) are supported.失败问题解决办法。
- 64位系统上设置编译平台为x86的VS2008项目升级到VS2010后编译失败的原因和解决办法
- Linux下librdkafka客户端的编译运行
- Eclipse下无法自动编译,或者WEB-INF/classes目录下没文件,编译失败的解决办法
- 把一个动态库改成静态编译库时提示MSVCRTD.lib已经在××中编译过的错误的解决办法
- VS 2010编译错误解决办法之---- LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- zlib 在 Visual Studio 2005 下编译失败的解决办法
- 编译QT时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法
- zlib 在 Visual Studio 2005 下编译失败的解决办法
- 【Android】Lenovo K860 framework-res.apk回编译失败解决办法
- AIX6.1下编译librdkafka
- 编译安装php报错PHP configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解决办法
- zlib 在 Visual Studio 2005 下编译失败的解决办法
- NDK编译可执行文件在Android L中运行显示error: only position independent executables (PIE) are supported.失败问题解决办法。
- RK3288-OTA编译失败解决办法【转】
- VS2008编译DirectX SDK 2004 summer版的Sound例子程序出现的libcp.lib找不到的问题的解决办法
- mac osx 下gcc升级导致sac101.6a编译失败解决办法
- Xamarin.IOS binding库编译失败的解决办法