LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-24-2011, 06:23 PM   #1
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Rep: Reputation: 35
Question What happens when shared library not available?


Hello

I'm trying to investigate why Lua fails loading a module on an appliance running uClinux:

Code:
appliance> ./lua -l luasql.sqlite3
./lua: can't resolve symbol '_luaL_ref'
When running ldd on a workstation...
Code:
workstation#/opt/uClinux-2010/bfin-linux-uclibc/bin/bfin-linux-uclibc-ldd
/var/tmp/lua-5.1.4/src/lua

ldd: can't map cache '/etc/ld.so.cache'
checking sub-depends for 'not found'
checking sub-depends for 'not found'
checking sub-depends for '/lib/libgcc_s.so.1'
checking sub-depends for 'not found'
checking sub-depends for '/lib/libc.so.6'
        libdl.so.0 => not found (0x00000000)
        libm.so.0 => not found (0x00000000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000)
        libc.so.0 => not found (0x00000000)
        libc.so.6 => /lib/libc.so.6 (0x00000000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
... and then checking which libraries are available on the appliance...

Code:
appliance> find / -name "libdl.so.0"
/lib/libdl.so.0
appliance> find / -name "libm.so.0"
/lib/libm.so.0
appliance> find / -name "libgcc_s.so.1"
/lib/libgcc_s.so.1
appliance> find / -name "libc.so.0"
/lib/libc.so.0
appliance> find / -name "libc.so.6"
appliance> find / -name "ld-linux*"
appliance>
... it appears that a couple of them are missing.

Could those two missing shared libraries explain the issue I'm having?

Incidenty, is the source code for "ldd" available, so I can try cross-compiling and running it on the appliance?

Thank you.
 
Old 01-25-2011, 11:10 AM   #2
reed9
Member
 
Registered: Jan 2009
Location: Boston, MA
Distribution: Arch Linux
Posts: 653

Rep: Reputation: 142Reputation: 142
ldd is provided by the GNU C library (glibc). Source code is available.
 
Old 01-25-2011, 08:11 PM   #3
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

From my point of view your problem is not directly "ldd" related. The problem is that it does not find a symbol which should belongs to your binary or maybe to a liblua.so... In any case it probably means that something weird happens during cross-compilation. So if you could provide us more info about your cross-compilation steps and also tell us if you did some source code change, it may help to understand why you get this error.

Kind regards,

Oliv'
 
Old 01-26-2011, 03:50 AM   #4
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
Thanks guys. It does look like a compile/linking issue, although no error occurs.

Here's what I did to compile the Lua interpreter, SQLite3, and LuaSQL + SQLite3:

Code:
# cat /var/tmp/lua-5.1.4/src/Makefile
export PATH:=$(PATH):/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin

TARGET_CROSS=bfin-linux-uclibc-
export CC=$(TARGET_CROSS)gcc
export STRIP=$(TARGET_CROSS)strip
export AR=$(TARGET_CROSS)ar rcu
export RANLIB=$(TARGET_CROSS)ranlib
export STAGING_DIR=/usr/src/baps/uClinux-dist/staging
export UCLINUX_LIB=/usr/src/baps/uClinux-dist/lib
export UCLINUX_ROOT_LIB=/usr/src/baps/uClinux-dist/root/lib
export CFLAGS=-O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I$(STAGING_DIR)/usr/include -DLUA_USE_POSIX -DLUA_USE_DLOPEN
export LDFLAGS= -L$(STAGING_DIR)/usr/lib -L$(UCLINUX_LIB) -L$(UCLINUX_ROOT_LIB) -ldl -lm

...
$(LUA_T): $(LUA_O) $(LUA_A)
        $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(LUA_O) $(LUA_A)

$(LUAC_T): $(LUAC_O) $(LUA_A)
        $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(LUAC_O) $(LUA_A)
...
generic:
        $(MAKE) all

# cat /var/tmp/sqlite-amalgamation-3070400/Makefile
export PATH:=$(PATH):/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin

TARGET_CROSS=bfin-linux-uclibc-
export CC=$(TARGET_CROSS)gcc
export STRIP=$(TARGET_CROSS)strip
export AR=$(TARGET_CROSS)ar rcu
export RANLIB=$(TARGET_CROSS)ranlib
export CFLAGS=-O2 -Wall

libsqlite3.o:
        $(CC) $(CFLAGS) -DSQLITE_THREADSAFE=0 -o $@ -c sqlite3.c

# cat /var/tmp/luasql-2.1.1/config
...
LUA_INC= /var/tmp/lua-5.1.4/src
LIB_OPTION= -shared #for Linux
...
DRIVER_LIBS= /var/tmp/sqlite-amalgamation-3070400/libsqlite3.o
DRIVER_INCS= -I/var/tmp/sqlite-amalgamation-3070400

WARN= -Wall
INCS= -I$(LUA_INC)
CFLAGS= -O2 $(WARN) -I$(COMPAT_DIR) $(DRIVER_INCS) $(INCS) $(DEFS)
CC=/usr/src/baps/opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc
LDFLAGS = -Wl,--trace,--print-map,--cref

# cat /var/tmp/luasql-2.1.1/Makefile
...
src/$(LIBNAME): $(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(DRIVER_LIBS) $(LIB_OPTION)
Based on the error message, it looks like it's due to faulty compiling of Lua or LuaSocket, but I don't know how else to compile those two parts.

Thanks for any help.
 
Old 01-26-2011, 05:35 AM   #5
littlebigman
Member
 
Registered: Aug 2008
Location: France
Posts: 658

Original Poster
Rep: Reputation: 35
After being told that it was most likely a linking issue, and after more reading and trial/error, I finally found what it was: When building Lua, the following options are required: "-Wl,-E"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shared library : libfg.so: cannot open shared object file error 40 x_gaurav Programming 2 06-28-2009 06:29 AM
ldd reports shared library missing, but library exists on disk athv_gr Linux - Newbie 7 05-13-2009 12:31 PM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration