error while loading shared libraries BBB 4.1.12-ti-r29

My BBB setup is as follows …
Linux beaglebone 4.1.12-ti-r29 #1 SMP PREEMPT Mon Nov 9 22:46:19 UTC 2015 armv7l GNU/Linux
BeagleBoard.org Debian Image 2015-11-12

For whatever reason I cannot access a library (i.e. libEBBLibrary.so) and I am not sure what I am missing. Might someone offer a suggestion on where I am going wrong or what I can do to rectify it?? Thanks in advance who those that reply.
root@beaglebone:~/exploringBB/chp09/LCDcharacter# sudo sh -c “echo BB-SPIDEV1 > $SLOTS”

root@beaglebone:~/exploringBB/chp09/LCDcharacter# cat $SLOTS|grep SPI

4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

root@beaglebone:~/exploringBB/chp09/LCDcharacter# ./build

root@beaglebone:~/exploringBB/chp09/LCDcharacter# ./LCDApp

./LCDApp: error while loading shared libraries: libEBBLibrary.so: cannot open shared object file: No such file or directory

root@beaglebone:~/exploringBB/chp09/LCDcharacter# g++ LCDApp.cpp …/…/library/libEBBLibrary.so -o LCDApp -I “…/…/library”

root@beaglebone:~/exploringBB/chp09/LCDcharacter# ./LCDApp

./LCDApp: error while loading shared libraries: libEBBLibrary.so: cannot open shared object file: No such file or directory

root@beaglebone:~/exploringBB/chp09/LCDcharacter# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

root@beaglebone:~/exploringBB/chp09/LCDcharacter# export LD_LIBRARY_PATH="…/…/library/libEBBLibrary.so:$LD_LIBRARY_PATH"
root@beaglebone:~/exploringBB/chp09/LCDcharacter# ./LCDApp
./LCDApp: error while loading shared libraries: libEBBLibrary.so: cannot open shared object file: No such file or directory

Well "No such file or directory"..

and it's not available:

https://packages.debian.org/search?searchon=contents&keywords=libEBBLibrary.so&mode=exactfilename&suite=stable&arch=any

So, you better check where you built "LCDApp", and fix your error..

Regards,

I don’t believe that LD_LIBRARY_PATH is searched in the manner you’re thinking in the last lines. If memory serves you need to specify the full path from / i.e. absolute not relative. Mike

Also, using LD_LIBRARY_PATH in this manner is just flat out wrong. If you have a shared library file, put it in the correct directory to begin with.

Exactly my thoughts William. As a sys admin I’ve seen way to much LD_* abuse not just LD_LIBRARY_PATH… It’s really not that hard on Linux, but if following other bad examples, well what can one say? Somewhere out there is a great reference on GCC, G++ and using libraries. The title or link eludes me now. Was from the UK somewhere I believe. Mike

Why do you think it's wrong? The point of LD_LIBRARY_PATH is to
collect all the places you might have shared libs, whether system or
application or private.
There's even another trick, using LD_PRELOAD to force certain library
into the image to override symbols from e.g. system libraries; this
works great for debugging.

BTW, if you need to add a library file or directory to a single
application, I'd recommend just setting the environment for this
single command rather than exporting it for general use:

LD_PRELOAD=/home/user/proj/lib/libdebug.so LCDApp

I'm not going debate the use of LD_LIBRARY_PATH, as an admin all I'll say is it's terribly abused and a security nightmare if not used properly.

Your example may well solve his issue and is a workable solution. Noting the the path is absolute and not relative...

Mike

All said something else is going on here. libEBBLibrary.so is definitely there yet it does not take. I should mention that namespace std is being used to make updates on code easier. See code listed below.

root@beaglebone:~/exploringBB/chp09/LCDcharacter# export LD_LIBRARY_PATH="~/exploringBB/library/libEBBLibrary.so:$LD_LIBRARY_PATH"

root@beaglebone:~/exploringBB/chp09/LCDcharacter# ./LCDApp

./LCDApp: error while loading shared libraries: libEBBLibrary.so: cannot open shared object file: No such file or directory

root@beaglebone:~/exploringBB/chp09/LCDcharacter# cd …/…/library

root@beaglebone:~/exploringBB/library# ls

CMakeLists.txt README build bus display docs example gpio libEBBLibrary.a libEBBLibrary.so motor network sensor

root@beaglebone:~/exploringBB/library#

Here is the code …

#include <unistd.h>
#include
#include
#include “display/LCDCharacterDisplay.h”
using namespace std;
using namespace exploringBB;

int main(){
cout << “Starting EBB LCD Character Display Example” << endl;
SPIDevice busDevice = new SPIDevice(2,0); //Using second SPI bus (both loaded)
busDevice->setSpeed(1000000); // Have access to SPI Device object
ostringstream s; // Using this to combine text and int data
LCDCharacterDisplay display(busDevice, 16, 2); // Construct 16x2 LCD Display
display.clear(); // Clear the character LCD module
display.home(); // Move the cursor to the (0,0) position
display.print(“EBB by D. Molloy”); // String to display on the first row
for(int x=0; x<=10000; x++){ // Do this 10,000 times
s.str(""); // clear the ostringstream object s
display.setCursorPosition(1,3); // move the cursor to second row
s << “X=” << x; // construct a string that has an int value
display.print(s.str()); // print the string X=
** on the LCD module
}
cout << “End of EBB LCD Character Display Example” << endl;
}

ldd and strace are probably the tools I would use to help debug this. Mike

Why do you think it’s wrong? The point of LD_LIBRARY_PATH is to
collect all the places you might have shared libs, whether system or
application or private.

Because it’s wrong. LD_LIBRARY_PATH is executation time, not link time. Link time is -L /path/to/lib( gcc / g++ )

http://unix.stackexchange.com/questions/168340/where-is-ld-library-path-how-do-i-set-the-ld-library-path-env-variable

Because it’s wrong. LD_LIBRARY_PATH is executation time, not link time. Link time is -L /path/to/lib( gcc / g++ )

What’s more, every user should have /usr/lib in their path . . .

Anyway, read this, and learn: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

I decided to close this post and repost as an strace question as it is more to the point. Thanks William for directing my attention to strace.