在 Mac OS X 上用 C 编译hiredis [英] Compile hiredis in C on Mac OS X

查看:113
本文介绍了在 Mac OS X 上用 C 编译hiredis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Mac OS X 上的 C 中使用 hiredis 编译客户端.

I'm trying to compile a client using hiredis in C on Mac OS X.

我已经安装了 hiredis:

brew install hiredis

但是还是报错:

fatal error: 'hiredis.h' file not found

我的 hiredis.h 然而在:

/usr/local/include/hiredis/hiredis.c

我如何告诉编译器这个?

How do I tell the compiler this?

我正在编译:

gcc test.c -o test

推荐答案

在您的问题中,您说 hiredis.h 位于 /usr/local/include/hiredis/hiredis.c,这真的没有任何意义.

In your question you said hiredis.h is in /usr/local/include/hiredis/hiredis.c, which doesn't really make any sense.

假设您的意思是您的 hiredis.h/usr/local/include/hiredis 中.你可以这样做:

Assuming you meant that your hiredis.h is in /usr/local/include/hiredis. You can do like:

gcc test.c -I/usr/local/include/hiredis -o test

在此 SO 帖子中了解 -I.

更新:

正如@EricPostpischil 在评论中提到的那样,最好只包含以下内容:

As mentioned by @EricPostpischil in comments, its a better idea to just include like:

#include < hiredis/hiredis.h>

我仍然不确定 /usr/local/include 是否在默认包含路径中.如果是,那么不需要做任何事情,只需像这样编译:

I am still not sure if /usr/local/include is in default include path. If it is, well no need to do anything, just compile like:

gcc test.c -o test

如果不是,

gcc test.c -I/usr/local/include -o test

这篇关于在 Mac OS X 上用 C 编译hiredis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆