code using libsoc compiles ok but when run get "cannot open shared object file"

Hello All,
I have modified the bipolar stepper motor code from the BeagleBone Cookbook (4.4) to use libsoc. I cloned libsoc from Git per the book. The code compiles with no errors but when I run it I get “error while loading shared libraries: cannot open shared object file: No such file or directory”. Itis only when I try to run the file the error comes up. The file is there I can see it. I added the directory to $PATH but still no joy. Does anyone know what is going on? I am running it fro Cloud9. I did notice the latest version of libsoc uses ‘LS_GPIO_SHARED’ instead of just ‘LS_SHARED’ as in the book so maybe something else changed.
Thanks for the help! Have a Blessed day!


What is the exact name of the book and who wrote it? I have some of the books that were produced and directed at the boards.

Please just give me the name of the book and the author(s). I can then review where you are in the book and try to revisit the items in question.

One thing, I can tell you this idea is factual, a lot has changed. In these changed things, like .dts, config-pin, kernel changes, and etc, I have noticed that not everything works from kernel to kernel.

This might be just me but I may make some time if I have the correct book you are describing. I was just reviewing an older book the other day. I just read your issue w/ the BeagleBone Cookbook.

Yoder, Mark A.; Kridner, Jason. BeagleBone Cookbook: Software and Hardware Problems and Solutions . O'Reilly Media. Kindle Edition. 

This one?

If so, please let me know what chapter you are on. This will cut down time spent reviewing the entire book over again.


P.S. Let me know when you have a section and we can work on it together. Who knows? We may be able to update it for future learners.

@DonTrustee ,

Okay, just an update here. Do not worry. If that is the book, the one in highlights above, I found the stepper motor concerns in question. Page 123?

Okay, so, if you are using Cloud 9, stop if you are using newer kernels, 4.19.x or 5.4.x and so on.

Try your own source in Python or C/C++ or even Node.js. I think Node.js has changed too in time. So, checking the nodejs versioning can be helpful while knowing what pins are available is helpful too.

I know nothing about libsoc. I will look it up later.


P.S. Please reply at will. libsoc? >>> libsoc ? I cannot find where it states to use libsoc yet. What page?

Kernel version is
Linux version 4.19.94-ti-r42 (voodoo@x3-am57xx-beagle-x15-2gb) (gcc version 8.3.0 (Debian 8.3.0-6)) #1buster SMP PREEMPT Tue Mar 31 19:38:29 UTC 2020
and the book is the Kridner/Yoder book of 2015 first edition. I am changing example 4.4 page 123 into using libsoc. I used the libsoc examples of 5-4 page 177 and Example 8-2 page 249. The compiler is invoker as: gcc-o myfile myfile.c /usr/local/lib/libsoc as per Example 8-2. Example 5-4 uses: gcc -o myfile myfile.c -lsoc . I tried both and both compile OK but both get the “error while loading shared libraries: cannot open shared object file: No such file or directory” error when running the program.
include files:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include “libsoc_gpio.h”
#include “libsoc_debug.h”

Instead of Cloud9 what are good development environments to use with version 4.19?
thanks for your help. Have a Blessed day!


I was unaware of you using the x15. Sorry. But, the good news outside of me not knowing anything about the x15 board from this .org.

Vi, vim, emacs, nano, bash, shell, any.


P.S. Cloud9 sort of, from what I understand, went to AWS services and they picked it up or something like that idea. Off to research it. Brb. I think beagleboard persons are moving towards a VS Code thing but I am not completely sure for online debugging. This is the AWS services I found for the newly, updated cloud9 IDE and plugin(s): AWS Cloud9 Amazon Web Services . I know that is not much help now. But it may save you from jumping into the online based debugging of hardware/software.

I’m in the process of updating the BeagleBone Cookbook for the 5.10 kernel. I’m moving away from BoneScript and moving to pure JavaScript, or Python. The realtime chapter has examples of c, python and JavaScript that might help getting your stepper motor going.

Unfortunately, I don’t have access to a stepper motor so I can’t convert the example at this time.


1 Like

I have working without bonescript.

Thank you for your reply. I have reviewed your code and its good to see how it is done that way. However, I was wanting to write the code using C, although I did not specifically say that in my post, using libsoc. My problem is not with my code, I believe, but with libsoc or the gcc compiler and the run tine execution. My c code compiles OK, no errors, it is only at runtime the error occurs. Somewhere the path to is lost. Is it a $PATH thing? Or a config file setting somewhere? I tried adding the path to it in $PATH, maybe I have to add it in the bash shell too? I still cannot get code using libsoc to run.

Mark Yoder do you still use libsoc in Examples 5-4 and 8-2? libsoc has changed since the first run of the Cookbook.

You are right silver2row I do not want to edit or debug online, thanks for that information, I had no idea about Cloud9.
Have a Blessed day!

Hello @DonTrustee ,

Seth here again. Maybe try to add the export of $PATH in .bashrc? This could be it. I know adding a export PATH=$PATH:/the/path/to/your/files/ in .bashrc sometimes works after adding the source to .bashrc like this:

  1. in the .bashrc file, export PATH=$PATH:/the/path/to/your/files
  2. source .bashrc

If that does not work even after a reboot or b/c of a reboot, please let me know.


P.S. I will review the libsoc C files soon to see if this is it. I will update you later in the week or next week.

Just a note to close this out. For some reason, not yet understood, libsoc is working. I powered down the BeagleBone Black and it is now working; but I did that before posting here. Anyway, I will not be using libsoc anyway, migrating to the new GPIO user space in Linux based on character devices since ver 4.8. Too bad it doesn’t have a more catchy name.
Have a Blessed day all!

1 Like