vsergeev / lua-periphery

A Lua library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
MIT License
186 stars 39 forks source link

Version 1.0.3 on raspbian - compile error #1

Closed 1linux closed 9 years ago

1linux commented 9 years ago

Current github version does not compile on raspbian / Lua 5.1 First you have to set include-path before make: export LUA_INCDIR=/usr/include/lua5.1 Then when compiling:

src/lua_i2c.c: In function ‘luaopen_periphery_i2c’: src/lua_i2c.c:371:5: error: ‘I2C_M_STOP’ undeclared (first use in this function) src/lua_i2c.c:371:5: note: each undeclared identifier is reported only once for each function it appears in Makefile:40: recipe for target 'periphery.so' failed

vsergeev commented 9 years ago

Which kernel version are you building for?

1linux commented 9 years ago

I tried again on a BananaPi, same issue... Version:

uname -a Linux lemaker 3.4.90 #2 SMP PREEMPT Tue Aug 5 14:11:40 CST 2014 armv7l GNU/Linu

cc -Wall -Wextra -Wno-unused-parameter -fPIC -I. -I/usr/include/lua5.1 -shared src/lua_periphery.c >src/lua_mmio.c src/lua_gpio.c src/lua_spi.c src/lua_i2c.c src/lua_serial.c c-periphery/periphery.a -o periphery.so src/lua_i2c.c: In function ‘luaopen_periphery_i2c’: src/lua_i2c.c:371:5: error: ‘I2C_M_STOP’ undeclared (first use in this function) src/lua_i2c.c:371:5: note: each undeclared identifier is reported only once for each function it appears in Makefile:40: recipe for target 'periphery.so' failed make: *\ [periphery.so] Error 1

When I define I2C_M_STOP manually it works... crazy.

vsergeev commented 9 years ago

Thanks. It appears I2C_M_STOP was added in kernel version 3.6. I'll add some #ifdefs so lua-periphery will only export the flags available in the linux headers it's built against. That should fix your issue and make the build more robust.

vsergeev commented 9 years ago

I've released v1.0.4 with this fix and updated moonrocks. Thanks again for reporting this.