在Mac OS X上编译lsyncd(Lion)

时间:2012-03-14 07:05:45

标签: compilation lua pkg-config

我正在尝试在Mac OS X(Lion)上编译lsyncd,但我的配置脚本无法找到我的lua库时遇到了一些问题: -

calvin$ ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking pkg-config is at least version 0.9.0... yes
checking for LUA... no
checking for LUA... no
checking for LUA... no
checking for LUA... no
configure: error: Package requirements (lua >= 5.1.3) were not met:
No package 'lua' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LUA_CFLAGS
and LUA_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

我确实通过macports安装了lua。

calvin$ lua -v
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
calvin$ which lua
/opt/local/bin/lua

更新

我确定lua.pc文件位于:

calvin$ sudo find /opt/local -name "lua.pc"
/opt/local/lib/pkgconfig/lua.pc

等等,在我的.bashrc文件中明确指定PKG_CONFIGPKG_CONFIG_PATH环境变量并获取它的程度。像这样:

export PKG_CONFIG="/opt/local/lib/pkgconfig:$PKG_CONFIG"
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"

我需要做些什么来设置正确的PKG_CONFIG_PATH环境变量,以便我的配置脚本可以找到lua?

更新#2

所以我添加了

export LUA_CFLAGS="/opt/local/include"
export LUA_LIBS="/opt/local/lib"

在我的.bashrc文件中,完成后,我现在可以成功运行./configure --without-inotify,输出如下: -

calvin$ ./configure --without-inotify
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking pkg-config is at least version 0.9.0... yes
checking for LUA... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/inotify.h usability... no
checking sys/inotify.h presence... no
checking for sys/inotify.h... no
compiling without inotify
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

不幸的是,运行make不起作用,因为lsyncd.h标头文件似乎无法包含lua.h

calvin$ make
make  all-am
gcc -DHAVE_CONFIG_H -I.     -g -O2 -Wall /opt/local/include -MT lsyncd.o -MD -MP -MF .deps/lsyncd.Tpo -c -o lsyncd.o lsyncd.c
In file included from lsyncd.c:16:
lsyncd.h:27:17: error: lua.h: No such file or directory
In file included from lsyncd.c:16:
lsyncd.h:52: error: expected ‘)’ before ‘*’ token
lsyncd.h:55: error: expected ‘)’ before ‘*’ token
lsyncd.h:88: error: expected ‘)’ before ‘*’ token
lsyncd.h:115: error: expected ‘)’ before ‘*’ token
lsyncd.h:118: error: expected ‘;’ before ‘void’
lsyncd.h:130: error: expected ‘)’ before ‘*’ token
lsyncd.h:131: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
lsyncd.c:44:20: error: lualib.h: No such file or directory
lsyncd.c:45:21: error: lauxlib.h: No such file or directory
lsyncd.c:64:3: error: #error "need at least one notifcation system. please rerun ./configure"
lsyncd.c:175:3: warning: #warning having to use old style realpath()
lsyncd.c:337: error: expected ‘)’ before ‘*’ token
lsyncd.c:432: error: expected ‘)’ before ‘*’ token
lsyncd.c: In function ‘pipe_tidy’:
lsyncd.c:453: error: ‘struct observance’ has no member named ‘extra’
lsyncd.c: At top level:
lsyncd.c:522: error: expected ‘)’ before ‘*’ token
lsyncd.c:564: error: expected ‘)’ before ‘*’ token
lsyncd.c:565: error: expected ‘;’, ‘,’ or ‘)’ before ‘void’
lsyncd.c: In function ‘nonobserve_fd’:
lsyncd.c:650: error: ‘struct observance’ has no member named ‘tidy’
lsyncd.c: At top level:
lsyncd.c:662: error: expected ‘)’ before ‘*’ token
lsyncd.c:689: error: expected ‘)’ before ‘*’ token
lsyncd.c:730: error: expected ‘)’ before ‘*’ token
lsyncd.c:731: error: expected ‘)’ before ‘*’ token
lsyncd.c:740: error: expected ‘)’ before ‘*’ token
lsyncd.c:800: error: expected ‘)’ before ‘*’ token
lsyncd.c:821: error: expected ‘)’ before ‘*’ token
lsyncd.c:968: error: expected ‘)’ before ‘*’ token
lsyncd.c:1011: error: expected ‘)’ before ‘*’ token
lsyncd.c:1045: error: expected ‘)’ before ‘*’ token
lsyncd.c:1097: error: expected ‘)’ before ‘*’ token
lsyncd.c:1111: error: expected ‘)’ before ‘*’ token
lsyncd.c:1186: error: expected ‘)’ before ‘*’ token
lsyncd.c:1241: error: expected ‘)’ before ‘*’ token
lsyncd.c:1268: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘lsyncdlib’
lsyncd.c:1286: error: expected ‘)’ before ‘*’ token
lsyncd.c:1309: error: expected ‘)’ before ‘*’ token
lsyncd.c:1334: error: expected ‘)’ before ‘*’ token
lsyncd.c:1346: error: expected ‘)’ before ‘*’ token
lsyncd.c:1358: error: expected ‘)’ before ‘*’ token
lsyncd.c:1371: error: expected ‘)’ before ‘*’ token
lsyncd.c:1423: error: expected ‘)’ before ‘*’ token
lsyncd.c:1449: error: expected ‘)’ before ‘*’ token
lsyncd.c:1497: error: expected ‘)’ before ‘*’ token
lsyncd.c: In function ‘main1’:
lsyncd.c:1669: error: ‘lua_State’ undeclared (first use in this function)
lsyncd.c:1669: error: (Each undeclared identifier is reported only once
lsyncd.c:1669: error: for each function it appears in.)
lsyncd.c:1669: error: ‘L’ undeclared (first use in this function)
lsyncd.c:1677: warning: implicit declaration of function ‘lua_open’
lsyncd.c:1678: warning: implicit declaration of function ‘luaL_openlibs’
lsyncd.c:1683: warning: implicit declaration of function ‘lua_getglobal’
lsyncd.c:1684: warning: implicit declaration of function ‘luaL_checkstring’
lsyncd.c:1684: warning: assignment makes pointer from integer without a cast
lsyncd.c:1693: warning: implicit declaration of function ‘lua_pop’
lsyncd.c:1710: warning: implicit declaration of function ‘printlogf0’
lsyncd.c:1717: warning: implicit declaration of function ‘register_lsyncd’
lsyncd.c:1754: warning: implicit declaration of function ‘luaL_loadfile’
lsyncd.c:1755: warning: implicit declaration of function ‘lua_tostring’
lsyncd.c:1762: warning: implicit declaration of function ‘luaL_loadbuffer’
lsyncd.c:1776: warning: implicit declaration of function ‘lua_pcall’
lsyncd.c:1776: error: ‘LUA_MULTRET’ undeclared (first use in this function)
lsyncd.c:1780: warning: implicit declaration of function ‘lua_pushlightuserdata’
lsyncd.c:1782: warning: implicit declaration of function ‘lua_insert’
lsyncd.c:1784: warning: implicit declaration of function ‘lua_settable’
lsyncd.c:1784: error: ‘LUA_REGISTRYINDEX’ undeclared (first use in this function)
lsyncd.c:1789: warning: implicit declaration of function ‘lua_gettable’
lsyncd.c:1790: warning: implicit declaration of function ‘lua_pushstring’
lsyncd.c:1792: warning: implicit declaration of function ‘lua_remove’
lsyncd.c:1800: warning: assignment makes pointer from integer without a cast
lsyncd.c:1831: warning: implicit declaration of function ‘load_runner_func’
lsyncd.c:1847: warning: implicit declaration of function ‘lua_newtable’
lsyncd.c:1849: warning: implicit declaration of function ‘lua_pushnumber’
lsyncd.c:1866: warning: assignment makes pointer from integer without a cast
lsyncd.c:1930: warning: implicit declaration of function ‘lua_pushboolean’
lsyncd.c:1935: warning: implicit declaration of function ‘masterloop’
lsyncd.c:1943: error: ‘struct observance’ has no member named ‘tidy’
lsyncd.c:1965: warning: implicit declaration of function ‘lua_close’
make[1]: *** [lsyncd.o] Error 1
make: *** [all] Error 2

有什么建议吗?

1 个答案:

答案 0 :(得分:5)

已解决此问题

./configure --without-inotify --with-fsevents CFLAGS="-I /Users/calvin/xnu-1699.24.23/" LUA_CFLAGS="-I /opt/local/include" LUA_LIBS="/opt/local/lib/liblua.a" 

依赖关系是:

doc/lsyncd.1: doc/lsyncd.1.xml
xsltproc -o $@ -nonet /etc/asciidoc/docbook-xsl/manpage.xsl $<

doc/lsyncd.1: doc/lsyncd.1.xml
    xsltproc -o $@ -nonet /opt/local/etc/asciidoc/docbook-xsl/manpage.xsl $<

然后运行

make

应该成功编译lsyncd。