Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid ELF header error #80

Closed
exebetche opened this issue Sep 23, 2014 · 2 comments
Closed

invalid ELF header error #80

exebetche opened this issue Sep 23, 2014 · 2 comments

Comments

@exebetche
Copy link

Hi,
I compiled lgi on Ubuntu 14.04 32 bits and with lua 5.2.3 without error, but when I try to run an example, I get this:

lua: error loading module 'lgi.corelgilua51' from file '/home/user/rocks/share/lua/5.2/lgi.lua':
    /home/user/rocks/share/lua/5.2/lgi.lua: invalid ELF header
stack traceback:
    [C]: in ?
    [C]: in function 'require'
    /home/user/rocks/share/lua/5.2/lgi/core.lua:14: in main chunk
    [C]: in function 'require'
    /home/user/rocks/share/lua/5.2/lgi/init.lua:18: in main chunk
    [C]: in function 'require'
    /home/user/rocks/share/lua/5.2/lgi.lua:19: in main chunk
    [C]: in function 'require'
    cairo.lua:12: in main chunk
    [C]: in ?

I thought it was somehow compiled as 64-bits but it's not:

$ file corelgilua51.so 
corelgilua51.so: ELF 32-bit LSB  shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=41fb50617b1c73293a4151f69f7c4bca501feb75, not stripped

Here is the output of the luarocks command in case it helps:

$ luarocks install lgi
Installing http://www.luarocks.org/repositories/rocks/lgi-0.8.0-1.src.rock...
Using http://www.luarocks.org/repositories/rocks/lgi-0.8.0-1.src.rock... switching to 'build' mode
make -C lgi
make[1]: entrant dans le répertoire « /tmp/luarocks_lgi-0.8.0-1-2973/lgi/lgi »
pkg-config --exists 'gobject-introspection-1.0 >= 0.10.8' --print-errors
touch .depcheck
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o buffer.o buffer.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o callable.o callable.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o core.o core.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o gi.o gi.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o marshal.o marshal.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o object.o object.c
gcc -fPIC  -O2 -fPIC -I/usr/include/lua5.2 -pthread -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/gobject-introspection-1.0   -Wall -Wextra -O2 -g -c -o record.o record.c
gcc -shared  -o corelgilua51.so buffer.o callable.o core.o gi.o marshal.o object.o record.o -Wl,--export-dynamic -pthread -lgirepository-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lffi  
echo "return '0.8.0'" > version.lua
make[1]: quittant le répertoire « /tmp/luarocks_lgi-0.8.0-1-2973/lgi/lgi »
make -C lgi install
make[1]: entrant dans le répertoire « /tmp/luarocks_lgi-0.8.0-1-2973/lgi/lgi »
mkdir -p /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lib/lgi
cp corelgilua51.so /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lib/lgi
mkdir -p /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua
cp ../lgi.lua /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua
mkdir -p /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua/lgi
cp class.lua component.lua core.lua enum.lua ffi.lua init.lua log.lua namespace.lua package.lua record.lua version.lua version.lua /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua/lgi
cp: avertissement : le fichier source «version.lua» est mentionné plusieurs fois
mkdir -p /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua/lgi/override
cp override/cairo.lua override/Clutter.lua override/Gdk.lua override/Gio-DBus.lua override/Gio.lua override/GLib-Bytes.lua override/GLib-Error.lua override/GLib.lua override/GLib-Markup.lua override/GLib-Timer.lua override/GLib-Variant.lua override/GObject-Closure.lua override/GObject-Object.lua override/GObject-Type.lua override/GObject-Value.lua override/Gst.lua override/Gtk.lua override/PangoCairo.lua override/Pango.lua /home/user/rocks/lib/luarocks/rocks/lgi/0.8.0-1/lua/lgi/override
make[1]: quittant le répertoire « /tmp/luarocks_lgi-0.8.0-1-2973/lgi/lgi »
Updating manifest for /home/user/rocks/lib/luarocks/rocks

lgi 0.8.0-1 is now built and installed in /home/user/rocks (license: MIT/X11)

Thank you.

@pavouk
Copy link
Collaborator

pavouk commented Oct 9, 2014

This is really strange. From this message

/home/user/rocks/share/lua/5.2/lgi.lua: invalid ELF header

it looks as if Lua is trying to load lgi.lua as ELF binary *which must fail, since it is actually Lua source), but I'm completely clueless why is this happening.

I also noticed the line:
cp: avertissement : le fichier source «version.lua» est mentionné plusieurs fois

Could it be that you are overwriting lgi install tree where some remnants of previous installs are? Would installing into clear tree help?

@exebetche
Copy link
Author

Thank's, you 're right, I think I used a "package.path" instead of "package.cpath" to link the library in the sample file, sorry about that.
About the cp warning, "version.lua" is indeed mentioned twice in the command (one line up). I think it is captured in both $(CORESOURCES) and $(VERSION_FILE) in ./lgi/lgi/Makefile:
cp $(CORESOURCES) $(VERSION_FILE) $(DESTDIR)$(LUA_SHAREDIR)/lgi

Anyway, thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants