[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Compile error for struct on OS-X
- From: Coda Highland <chighland@...>
- Date: Wed, 30 Mar 2016 09:57:45 -0700
Probably you're going to need to make a portfile for a
"lua51-luarocks" that changes the library dependency. This is how
Python stuff does it (e.g. py27-yaml) in MacPorts.
I don't remember offhand how to create a local ports overlay, but IIRC
it's not that hard.
/s/ Adam
On Wed, Mar 30, 2016 at 9:20 AM, Dan Christian <danchristian65@gmail.com> wrote:
> Thanks, that was very helpful. I had removed lua-5.3.
>
> I really need lua5.1 because it's compatible with luajit. When I have
> ports install luarocks, it's pulling in 5.3 as a dependency.
>
> Now I just need to either figure out how to get macports to install a
> lua5.1 versions of luarocks, lua-luajson, lua-luasocket, lua-luasec or
> build all that from source.
>
> Dan
>
>
> On Tue, Mar 29, 2016 at 5:45 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
>> Am 30.03.2016 um 01:46 schröbte Dan Christian:
>>>
>>> I'm trying to install struct on OS-X (10.11), and am getting compile
>>> errors. I'm new to Lua, so I might be missing something obvious. The
>>> details are at the end:
>>>
>>> I have Lua51 installed via macports, along with luarocks. I'll
>>> primarily be using it with luajit.
>>
>>
>> You are not using Lua 5.1 at the moment. You are using Lua 5.3. See below.
>>
>>>
>>> Anybody have this working?
>>>
>>> Is there a way to get luarocks to use gcc?
>>
>>
>> Yes, you can append the CC and LD variables to your LuaRocks incantation:
>>
>> luarocks install struct CC='env MACOSX_DEPLOYMENT_TARGET=10.8 gcc'
>> LD='env MACOSX_DEPLOYMENT_TARGET=10.8 gcc'
>>
>> (you can also add those to your config file to make them permanent.)
>>
>>>
>>> Where would I send a bug?
>>
>>
>> This list is usually a good start if you don't know a better place.
>>
>>>
>>> Thanks,
>>>
>>> Dan
>>>
>>>
>>> sudo luarocks install struct
>>>
>>> Installing https://luarocks.org/struct-1.2-2.src.rock...
>>
>>
>> This version is pretty old. The latest version available on LuaRocks is
>> 1.4-1, but that version specifies that it is only compatible with Lua >= 5.1
>> and < 5.3. Since this later version isn't chosen, we can deduce that
>> LuaRocks assumes that you don't have Lua 5.1 or 5.2 installed. The old 1.2-1
>> version *should* have specified that it is only compatible with Lua 5.1, but
>> back in the day folks were overly optimistic about compatibility with future
>> Lua versions.
>>
>>>
>>> Using https://luarocks.org/struct-1.2-2.src.rock... switching to 'build'
>>> mode
>>>
>>> env MACOSX_DEPLOYMENT_TARGET=10.8 /usr/bin/clang -O2 -fPIC
>>> -I/opt/local/include -c struct.c -o struct.o
>>>
>>> struct.c:181:27: warning: implicit declaration of function
>>> 'luaL_putchar' is invalid in C99 [-Wimplicit-function-declaration]
>>>
>>> while (toalign-- > 0) luaL_putchar(&b, '\0');
>>>
>>> ^
>>
>>
>> `luaL_putchar` was a thing in Lua 5.0. Lua 5.1 still had it for
>> compatibility. Lua 5.2 and 5.3 don't have that function/macro anymore. Did I
>> mention that the struct-1.2-2 version is pretty old?!
>>
>>>
>>> struct.c:318:37: error: array has incomplete element type 'const
>>> struct luaL_reg'
>>>
>>> static const struct luaL_reg thislib[] = {
>>>
>>> ^
>>
>>
>> `luaL_reg` was renamed to `luaL_Reg` in Lua 5.1 (which also supported the
>> old name for compatiblity). Lua 5.2 and 5.3 don't.
>>
>>>
>>> struct.c:318:21: note: forward declaration of 'struct luaL_reg'
>>>
>>> static const struct luaL_reg thislib[] = {
>>>
>>> ^
>>>
>>> struct.c:326:3: warning: implicit declaration of function
>>> 'luaL_register' is invalid in C99 [-Wimplicit-function-declaration]
>>>
>>> luaL_register(L, "struct", thislib);
>>>
>>> ^
>>
>>
>> `luaL_register` is deprecated (but available) in Lua 5.2, and gone by
>> default in Lua 5.3.
>>
>>>
>>> 2 warnings and 1 error generated.
>>>
>>>
>>> Error: Build error: Failed compiling object struct.o
>>>
>>>
>>
>>
>> I've attached a new rockspec that works[*] for Lua 5.3. Download it and use
>> it like this:
>>
>> luarocks install struct-1.4-2.rockspec
>>
>> Lua 5.3 has string (un)packing built-in, btw. Alternatively you can really
>> install Lua 5.1 and configure LuaRocks to use that version.
>>
>> HTH,
>> Philipp
>>
>>
>> [*]: Builds at least. The code is the same as for version 1.4-1, but the
>> test script asserts on my machine for Lua 5.1, 5.2, and 5.3.
>>
>>
>