ruby LoadError for .so file - ruby

I'm working with ruby1.8.7 on an embedded platform, and I'm trying to port the ruby sqlite3 gem onto the platform.
The underlying sqlite3_native.so makes successfully, and is installed on the target. ldd indicates that all dependencies are met. However, when I try to load it, I get a LoadError (File not Found). Other .so libraries in the same directory load successfully.
#ls -l
total 167
lrwxrwxrwx 1 root root 7 Oct 10 16:24 di.so -> di.so.5
-rw-r--r-- 1 root root 16540 Oct 10 15:29 di.so.5
-rwxrwxrwx 1 root root 37916 Mar 6 2012 serialport.so
-rwxrwxrwx 1 root root 51375 Oct 16 17:25 sqlite3_native.so
#[path_to_ruby]/bin/ruby -r ./di -e exit
#
#[path_to_ruby]/bin/ruby -r ./serialport -e exit
#
#[path_to_ruby]/bin/ruby -r ./ssqlite3_native -e exit
./sqlite3_native.so: File not found - ./sqlite3_native.so (LoadError)
Does anyone have any thoughts on possible causes?
Kind regards
Steve

The power of taking a walk to clear one's head....
The issue is in the linking of the library in the make process, not on the target machine.
The mkmf generated makefile links in libruby.so via the line
LIBS = $(LIBRUBYARG_SHARED) -lsqlite3 -lrt -ldl -lcrypt -lm -lc
removing libruby ( $(LIBRUBYARG_SHARED) ) changes the generated library in some subtle way (it is 20 bytes smaller) which then allows the ruby executable to locate and load the library.

Related

dtruss on OSX 10.9 Mavericks

I'm running OSX Mavericks. As I heard(WWDC 2013, 402-HD.mov) the clang compiler resides now here: -rwxr-xr-x 1 root wheel 29381728 Oct 23 08:40 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
In /usr/bin there's only a wrapper for clang(we can see that from the size):
-rwxr-xr-x 1 root wheel 14224 Oct 22 21:25 /usr/bin/clang
I want to compile one simple C file with clang.
"clang main.c", and I get the a.out (0 errors, 0 warnings). All OK.
Now (the problem) I want to run dtruss on that command line: "sudo dtruss -f clang main.c" but I don't get an a.out. Why? (-f follow children as they are forked). I would have expected that the wrapper does a fork and an exec to the real compiler, but it seems it's not if I run it with dtruss.

pkg-config cannot find .pc files although they are in the path

I am seeing a strange issue with pkg-config on Mac OSX-Lion. When running the python setup for module that I downloaded I receive the following error:
aspen:python toddysm$ sudo ./setup.py install
Password:
`pkg-config --libs --cflags cld` returns in error:
Package cld was not found in the pkg-config search path.
Perhaps you should add the directory containing `cld.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cld' found
The `cld` C++ library is absent from this system. Please install it.
However when checking in the /usr/local/lib folder I see the libs and the .pc file is in the pkgconfig subfolder
aspen:~ toddysm$ cd /usr/local/lib/
aspen:lib toddysm$ ls -al
total 2640
drwxr-xr-x 6 root wheel 204 Jul 2 17:38 .
drwxr-xr-x 9 root wheel 306 Jul 2 15:17 ..
-rwxr-xr-x 1 root wheel 1339516 Jul 2 17:38 libcld.0.dylib
lrwxr-xr-x 1 root wheel 14 Jul 2 17:38 libcld.dylib -> libcld.0.dylib
-rwxr-xr-x 1 root wheel 918 Jul 2 17:38 libcld.la
drwxr-xr-x 3 root wheel 102 Jul 2 17:38 pkgconfig
aspen:lib toddysm$ cd pkgconfig/
aspen:pkgconfig toddysm$ ls -al
total 8
drwxr-xr-x 3 root wheel 102 Jul 2 17:38 .
drwxr-xr-x 6 root wheel 204 Jul 2 17:38 ..
-rw-r--r-- 1 root wheel 279 Jul 2 17:38 cld.pc
Setting PKG_CONFIG_PATH to point to /usr/local/lib/ using the command line doesn't help. Setting it into ~/.bash_profile for some reason makes pkg-config unrecognizable as command.
My assumption is that I am missing some dependency but not sure what. When trying the same on Linux I was missing the Python Dev package python2.7-dev but I am not sure how to check for this on Mac (whether is there or not).
Any help will be appreciated.
You can list the directories pkg-config looks in by default using:
pkg-config --variable pc_path pkg-config
PKG_CONFIG_PATH needs the full /usr/local/lib/pkgconfig pathname appended to the variable.
Environment variables need to be export'ed to be useful for commands. Try
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ pkg-config --libs --cflags cld
It seems that although the PKG_CONFIG_PATH was properly set the Python script was not picking it up. Looking at the script it starts pkg-config in a subprocess and I am not sure whether the environment variable information is passed to the subprocess.
Nevertheless I solved the issue by copying the libraries and the .cp file to /opt/local/lib/ which is the default folder where pkg-config looks.
you might try as follows:
brew install pkg-config
brew install libvirt
and it works for me.

compiling wget with static linking, self compiled (open)ssl library linking issue

I'm trying to compile wget with static linking, but I'm running into a problem with ssl.
My setup doesn't have ssl installed, so I had to compile it myself, it seemed to go ok, and this is the listing of /usr/local/ssh/lib:
/usr/local/ssl/lib> ls -la
total 2000
drwxr-xr-x 3 root root 4096 2012-03-22 14:28 .
drwxr-xr-x 9 root root 4096 2012-03-22 14:28 ..
-rw-r--r-- 1 root root 1752954 2012-03-22 14:28 libcrypto.a
-rw-r--r-- 1 root root 272388 2012-03-22 14:28 libssl.a
drw-r--r-- 2 root root 4096 2012-03-22 14:28 pkgconfig
When trying to configure the compilation:
wget-1.13> env LDFLAGS="-L/usr/local/ssh/lib" ./configure --with-ssl=openssl
.....
configure: error. openssl development libraries not found
Any hints what might be wrong ? I compiled openssl for linux-elf
Ok, looks like it's classical "can't read own writing" problem.
Above I was trying to link to ssh library, not ssl O_o.
For future reference, correct procedure to link and compile a static wget with openssl is:
$>env CPPFLAGS="-I/dir/to/openssl/include" LDFLAGS="-L/dir/to/ssl/lib" ./configure --with-ssl=openssl
Include could be ie:
~/openssl/openssl-0.9.8u/include (headers for the openssl that was compiled)
library could be in ie:
usr/local/ssl/lib (folder containing libssl.a)
Then compiling:
$>make CPPFLAGS="-I/dir/to/openssl/include" LDFLAGS="-L/dir/to/ssl/lib -all-static"
Binary will be in the src folder.
Note that on some systems the -all-static option should be just -static.

lib path on mac osx

I did install the libnfc 1.5.1 in the default directory (/usr/loca/
lib).
if i do an ls i see the libs there:
foo:libnfc-1.5.1 bar$ ls -l /usr/local/lib/libnfc*
-rwxr-xr-x 1 root wheel 62092 Nov 23 09:05 /usr/local/lib/libnfc.2.dylib
-rw-r--r-- 1 root wheel 226696 Nov 23 09:05 /usr/local/lib/libnfc.a
lrwxr-xr-x 1 root wheel 14 Nov 23 09:05 /usr/local/lib/libnfc.dylib ->libnfc.2.dylib
-rwxr-xr-x 1 root wheel 930 Nov 23 09:05 /usr/local/lib/libnfc.la
foo:libnfc-1.5.1 bar$
I did try to run the configure script from mfoc with the following command:
LDFLAGS="-L/usr/local/lib" ./configure
it says that I don't have libnfc >= 1.5.1
checking for LIBNFC... no
configure: error: libnfc >= 1.5.1 is mandatory.
any idea?
This is a guess, but the error looks like it comes from pkg-config. Try:
$ ./configure LDFLAGS=-L/usr/local/lib PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
You really need to look in config.log to see exactly why it cannot find the library.
EDIT: It has often been claimed that pkg-config is fundamentally broken. This case has finally persuaded me that that is indeed true. Setting LDFLAGS should be sufficient, and the fact that it isn't renders this configure script broken. With that in mind, it might be better to disable pkg-config by running configure with the argument PKG_CONFIG=:
Try setting DYLD_LIBRARY_PATH variable and point it to /usr/local/lib before running ./configure:
$ export DYLD_LIBRARY_PATH=/usr/local/lib
$ ./configure

ld can't find X11 library on OSX Leopard

I have a pretty basic X11 app that I run on Linux that I'm trying to get compiled under OSX 10.5.8. I have X11 and the X11 SDK installed, and modified the makefile as follows:
CFLAGS = -L/usr/X11/lib -I/usr/X11/include
Everything compiles fine, but the linker can't find the X11 lib.
ld: library not found for -lX11
I've looked on google, but the only other people I've found with this problem so far either didn't have the X11 SDK installed or didn't know about the -L flag.
Any ideas?
gcc SimpleXlibApp.c -o SimpleXlibApp -lX11 -L/usr/X11/lib -I/usr/X11/include
That line compiles the example here: http://en.wikipedia.org/wiki/Xlib
You may be looking in the wrong location for the library; it's certainly in a different location on my OS X box. Try typing:
locate libX11.dylib
and adding an appropriate path. E.g. on my system you'd need -L/usr/X11/lib/ in you CFLAGS.
-L/usr/X11/lib doesn't work with OSX 10.6 and it has libX11.dylib :
% ls -l /usr/X11/lib/libX11.*
lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/libX11.6.2.0.dylib# -> libX11.6.dylib
-rwxr-xr-x 1 root wheel 3578368 Jul 12 2010 /usr/X11/lib/libX11.6.dylib*
lrwxr-xr-x 1 root wheel 14 Jul 21 17:46 /usr/X11/lib/libX11.dylib# -> libX11.6.dylib

Resources