I got an error for luacrypto.c
https://github.com/mkottman/luacrypto/blob/master/src/lcrypto.c
When I compile using that library I get:
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include In file included from src/lcrypto.c:31:0: src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
Which gcc version is that?
I have the gcc-4.9.2-6.fc21.x86_64 one.
Just tested on Debian jessie (gcc 4.9.2) and I don't get that errors.
gcc -O2 -fPIC -I/usr/include/lua5.2 -c src/lcrypto.c -o src/lcrypto.o -I/usr/include/lua5.2
I don't know Fedora much. What version of Lua are you using? Did you install it from a package or did you compile it yourself?
I'm suspecting this might be related to having compiled Lua 5.2 with LUA_COMPAT_MODULE disabled.
I got lua-5.2.2-8.fc21.x86_64 from package. Maybe I have to compile it actually... I also installed lua-devel-5.2.2-8.fc21.x86_64 with yum.
Also try "sudo luarocks install luacrypto" but I got this (I don't know why before doesn't share full log):
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include
In file included from src/lcrypto.c:31:0:
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before numeric constant
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:44:0: warning: "lua_objlen" redefined
#define lua_objlen lua_rawlen
^
In file included from /usr/include/lua.h:16:0,
from src/lcrypto.c:30:
/usr/include/luaconf.h:301:0: note: this is the location of the previous definition
#define lua_objlen(L,i) lua_rawlen(L, (i))
^
Error: Build error: Failed compiling object src/lcrypto.o
Ok. I see what is going on. The thing is that Fedora adds #define LUA_COMPAT_ALL to luaconf.h and Debian does not.
If you open lauxlib.h you'll see at then that when compat mode is enabled, a stub for luaL_register is already provided and that is clashing with the new definition provided by LuaCrypto.
So I think the correct code would be:
#if LUA_VERSION_NUM >= 502
#if !defined(LUA_COMPAT_MODULE)
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
{
if (libname) lua_newtable(L);
luaL_setfuncs(L, l, 0);
}
#endif
#ifndef lua_objlen
#define lua_objlen lua_rawlen
#endif
#endif
So we could say that LuaCrypto can't be installed with Fedora Core 21. Could you change the issue description? I would provide a pull request for this, but this project seems abandoned, sadly.
Where I add that code? in lauxlib.h? and where?
You say "The thing is that Fedora adds #define LUA_COMPAT_ALL to luaconf.h and Debian does not." what does this means? Please be a little more pedagogic.
And please can you provide me a fast solution to go around the problem? And what title do you want? Tell me and I change it...
Sorry. I was in a rush before.
The code should be added in luacrypto.c, replacing these lines.
The thing about Fedora adding LUA_COMPAT_ALL was a remark on the difference between Linux distros and how they "package" certain software (Lua in this case). Fedora builds Lua in such a way that triggers this error you found. Debian does not. That is why I couldn't reproduce your error in my development environment.
The suggested title for this issue would be just "Fails to compile with Fedora Core 21"
As for a fast solution...
luarocks unpack luacrypto
cd luacrypto-0.3.2.-1/luacrypto-0.3.2
(edit src/lcrypto.c and change the code as suggested in the previous comment)
luarocks make luacrypto-0.3.2-1.rockspec
I hope this helps.
I do it but still same problem....:(
When does the problem appear now? When you do luarocks make luacrypto-0.3.2-1.rockspec ?
Please be more specific. (and if available, please provide the output of that command).
Yes, excuse:
This is the file https://gist.github.com/cryptid11/89bf0c6cc3ad90b17445
When I execute "luarocks make luacrypto-0.3.2-1.rockspec":
Before I got:
$ sudo luarocks make luacrypto-0.3.2-1.rockspec
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include
gcc: error: src/lcrypto.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
Error: Build error: Failed compiling object src/lcrypto.o
Then retrying magically I got "luacrypto 0.3.2-1 is now built and installed in /usr (license: MIT)"
But when I retry compile the program I got:
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include
In file included from src/lcrypto.c:31:0:
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before numeric constant
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:44:0: warning: "lua_objlen" redefined
#define lua_objlen lua_rawlen
^
In file included from /usr/include/lua.h:16:0,
from src/lcrypto.c:30:
/usr/include/luaconf.h:301:0: note: this is the location of the previous definition
#define lua_objlen(L,i) lua_rawlen(L, (i))
^
Error: Failed installing dependency: https://rocks.moonscript.org/luacrypto-0.3.2-1.src.rock - Build error: Failed compiling object src/lcrypto.o
Error. Exiting.
What do you mean by "retry compile"? Are you installing luacrypto explicitly or is it a dependency of another Lua rock?
The line Error: Failed installing dependency: https://rocks.moonscript.org/luacrypto-0.3.2-1.src.rock - Build error: Failed compiling object src/lcrypto.o makes me think that you're installing another thing that depends on luacrypto. What is that other thing?
I'm installing Fedora 21 right now so I can see the problem myself.
Well, I managed to install luacrypto using the steps I mentioned.
sudo yum install gcc-4.9.2-6.fc21.x86_64
sudo yum install luarocks
sudo yum install unzip
sudo yum install openssl-devel
sudo yum install lua-devel
mkdir luacrypto
cd luacrypto
luarocks unpack luacrypto
cd luacrypto-0.3.2-1/luacrypto-0.3.2
vi src/lcrypto.c # Here I applied the changes, the code posted in the gist is ok
[vagrant@localhost luacrypto-0.3.2]$ sudo luarocks make luacrypto-0.3.2-1.rockspec
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include
gcc -shared -o crypto.so -L/usr/lib src/lcrypto.o -L/usr/lib -Wl,-rpath,/usr/lib: -lcrypto
Updating manifest for /usr/lib/luarocks/rocks
No existing manifest. Attempting to rebuild...
luacrypto 0.3.2-1 is now built and installed in /usr (license: MIT)
[vagrant@localhost luacrypto-0.3.2]$ lua
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
> require "crypto"
>
Now, please tell me if you still have problems after following those steps. If you now install something that depends on luacrypto, it should pick up the rock you've just installed.
Hope this helps.
Yes, I told you I also got "luacrypto 0.3.2-1 is now built and installed in /usr (license: MIT)" after a first (mine it seems) error.
But when trying to install https://github.com/yagop/telegram-bot I got the same result... So, if it doesn't depend on luacrypto and gcc I wonder why I got this error.
Maybe it doesn't "see" my installation because at a certain poit it says:
Missing dependencies for oauth:
luacrypto
luasec
lbase64
Using https://rocks.moonscript.org/luacrypto-0.3.2-1.src.rock... switching to 'build' mode
Archive: 0.3.2.zip
0639ea2f65dbe5f11c2d874527f3019ce5293ac5
creating: luacrypto-0.3.2/
inflating: luacrypto-0.3.2/.gitignore
extracting: luacrypto-0.3.2/AUTHORS
inflating: luacrypto-0.3.2/CMakeLists.txt
inflating: luacrypto-0.3.2/COPYING
inflating: luacrypto-0.3.2/ChangeLog
inflating: luacrypto-0.3.2/INSTALL
inflating: luacrypto-0.3.2/Makefile.am
inflating: luacrypto-0.3.2/Makefile.in
extracting: luacrypto-0.3.2/NEWS
inflating: luacrypto-0.3.2/README
inflating: luacrypto-0.3.2/aclocal.m4
inflating: luacrypto-0.3.2/config.guess
inflating: luacrypto-0.3.2/config.h.in
inflating: luacrypto-0.3.2/config.sub
inflating: luacrypto-0.3.2/configure
inflating: luacrypto-0.3.2/configure.ac
inflating: luacrypto-0.3.2/depcomp
inflating: luacrypto-0.3.2/dist.cmake
creating: luacrypto-0.3.2/doc/
inflating: luacrypto-0.3.2/doc/Makefile.am
inflating: luacrypto-0.3.2/doc/Makefile.in
creating: luacrypto-0.3.2/doc/us/
inflating: luacrypto-0.3.2/doc/us/examples.html
inflating: luacrypto-0.3.2/doc/us/index.html
inflating: luacrypto-0.3.2/doc/us/license.html
inflating: luacrypto-0.3.2/doc/us/luacrypto-128.png
inflating: luacrypto-0.3.2/doc/us/manual.html
inflating: luacrypto-0.3.2/install-sh
inflating: luacrypto-0.3.2/ltmain.sh
inflating: luacrypto-0.3.2/luacrypto.pc.in
inflating: luacrypto-0.3.2/luacrypto.sln
inflating: luacrypto-0.3.2/luacrypto.vcproj
creating: luacrypto-0.3.2/m4/
inflating: luacrypto-0.3.2/m4/libtool.m4
inflating: luacrypto-0.3.2/m4/ltoptions.m4
inflating: luacrypto-0.3.2/m4/ltsugar.m4
inflating: luacrypto-0.3.2/m4/ltversion.m4
inflating: luacrypto-0.3.2/m4/lt~obsolete.m4
inflating: luacrypto-0.3.2/missing
creating: luacrypto-0.3.2/rockspecs/
inflating: luacrypto-0.3.2/rockspecs/luacrypto-git-1.rockspec
creating: luacrypto-0.3.2/src/
inflating: luacrypto-0.3.2/src/Makefile.am
inflating: luacrypto-0.3.2/src/Makefile.in
inflating: luacrypto-0.3.2/src/lcrypto.c
inflating: luacrypto-0.3.2/src/lcrypto.h
creating: luacrypto-0.3.2/tests/
inflating: luacrypto-0.3.2/tests/Makefile.am
inflating: luacrypto-0.3.2/tests/Makefile.in
creating: luacrypto-0.3.2/tests/ca/
inflating: luacrypto-0.3.2/tests/ca/README
inflating: luacrypto-0.3.2/tests/ca/ca.crt
inflating: luacrypto-0.3.2/tests/ca/ca.key
inflating: luacrypto-0.3.2/tests/ca/server.crt
inflating: luacrypto-0.3.2/tests/ca/server.csr
inflating: luacrypto-0.3.2/tests/ca/server.key
inflating: luacrypto-0.3.2/tests/ca/server.key.insecure
inflating: luacrypto-0.3.2/tests/encrypt.lua
extracting: luacrypto-0.3.2/tests/message
inflating: luacrypto-0.3.2/tests/open_seal.lua
inflating: luacrypto-0.3.2/tests/pkeytest.lua
inflating: luacrypto-0.3.2/tests/rand.lua
inflating: luacrypto-0.3.2/tests/run-tests
inflating: luacrypto-0.3.2/tests/test.lua
extracting: luacrypto-0.3.2/tests/tmp.rnd
inflating: luacrypto-0.3.2/tests/x509_ca.lua
gcc -O2 -fPIC -I/usr/include -c src/lcrypto.c -o src/lcrypto.o -I/usr/include
In file included from src/lcrypto.c:31:0:
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before ‘(’ token
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:38:13: error: expected declaration specifiers or ‘...’ before numeric constant
static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l)
^
src/lcrypto.c:44:0: warning: "lua_objlen" redefined
#define lua_objlen lua_rawlen
^
In file included from /usr/include/lua.h:16:0,
from src/lcrypto.c:30:
/usr/include/luaconf.h:301:0: note: this is the location of the previous definition
#define lua_objlen(L,i) lua_rawlen(L, (i))
^
Error: Failed installing dependency: https://rocks.moonscript.org/luacrypto-0.3.2-1.src.rock - Build error: Failed compiling object src/lcrypto.o
Error. Exiting.
Do you have any hypothesis?
Having described the whole picture earlier would have saved a lot of time :smile: Just took a look at telegram-bot and I saw that it is installing its own version of LuaRocks isolated from the rest of the system. So that's why it does not see your luacrypto install.
To work around this issue, you can do the following. You can pack your installed luacrypto, modify the telegram-bot installation script and install luacrypto before this line
To pack the rock, do luarocks pack luacrypto. You'll get a file called luacrypto-0.3.2-1.linux-x86_64.rock
To install it: luarocks install luacrypto-0.3.2-1.linux-x86_64.rock
luarocks install can take a /path/to/your/rock so take note of that when editing telegram-bot's install script. The modification should look something like:
./.luarocks/bin/luarocks install luacrypto-0.3.2-1.linux-x86_64.rock
./.luarocks/bin/luarocks install oauth
(etc)
I did luarocks install lapis --local and require "lapis" fails requiring crypto.
trying to install luacrypto with luarocks the same way. and I am getting a compilation error.
src/lcrypto.c: In function ‘luaopen_crypto’:
src/lcrypto.c:1901:19: error: array type has incomplete element type ‘struct luaL_reg’
struct luaL_reg core[] = {
^
Error: Build error: Failed compiling object src/lcrypto.o
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-5-20150519/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --with-default-libstdcxx-abi=c++98
Thread model: posix
gcc version 5.1.0 (GCC)
Same issue here.
Works fine on alpine linux but failed on debian and ubuntu. (latest version) I had tried gcc-4.8, gcc-4.9, gcc-6.3, gcc-7 But all of them gave me the same error.
Same issue here.
Works fine on alpine linux but failed on debian and ubuntu. (latest version) I had tried gcc-4.8, gcc-4.9, gcc-6.3, gcc-7 But all of them gave me the same error.
just do apt-get install libssl1.0-dev
Same problem, but solved finally. CentOS Linux release 8.0.1905 (Core) , Lua 5.3.4, and openssl-devel-1.1.1c-15.el8.x86_64
go pull codes from https://github.com/evanlabs/luacrypto, which fixed openssl compatibility problems, and also do the trick that @ignacio commented on 29 Apr 2015
#if LUA_VERSION_NUM >= 502 #if !defined(LUA_COMPAT_MODULE) static void luaL_register (lua_State *L, const char *libname, const luaL_Reg *l) { if (libname) lua_newtable(L); luaL_setfuncs(L, l, 0); } #endif #ifndef lua_objlen #define lua_objlen lua_rawlen #endif #endif
make && make install
done!