jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.76k stars 616 forks source link

Dockerfile - Building the Shared Library in a Dockerfile #451

Closed adrian-patterson closed 3 years ago

adrian-patterson commented 3 years ago

I am facing an issue when trying to implement this library in a .net core application using Docker. If anyone has successfully built the shared C library (ws2811.so) in a Dockerfile, I'd love to see how it was done.

I am running a .net core application using a Dockerfile, and am trying to get this library to work. After following the build instructions, I am getting the following System.DllNotFoundException:

System.DllNotFoundException: Unable to load shared library 'ws2811.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libws2811.so: cannot open shared object file: No such file or directory

So it seems as if the ws2811.so shared library is not found from the server, even though I've included in the Raspberry Pi's /usr/lib and /usr/local/lib directories. I have also confirmed that the ws2811.so library is installed correctly on the device, as the test from the repo ran successfully. Not sure where to go from here, hopefully there is someone who could help me on this. Thanks!

NOTE: Also reported in Dockerfile - Unable to load shared library 'ws2811.so' #5

adrian-patterson commented 3 years ago

Solution

To any future readers, I've figured out how to include the shared library within a docker image. The following steps describe what needs to be done:

  1. First build the library to obtain ws2811.s0, following the build instructions (as linked in original issue)
  2. Include this library in the working directory of your docker file
  3. Copy the shared library into the docker image using COPY ws2811.so ./

And it works like a charm! Check out my Stackoverflow post for more details.

Cheers

qaniqani commented 2 years ago

Hi @canadrian72 I am having similar problem at operating system level. I'm not using Docker. But I couldn't find a solution. I put the ws2811 file next to my working files and under usr/lib, usr/local/lib but it didn't work. Are you still interested in the subject? Regards.

adrian-patterson commented 2 years ago

I'm not sure I could help you at an operating system level, but I would say the shared library is probably not in the right place or not configured correctly.

I ended up using python as the installation is much easier. The library can easily be installed through pip and it is much more elegant. In docker I simply pip install the library and all works well. Maybe open a new issue or post to stack overflow with more specifics if you're looking for help.

Best of luck!

qaniqani commented 2 years ago

Thanks, I solved the problem. In fact, it can be said that it is the same problem you have in Docker. After performing pip installation and configuration at OS level, I ran it successfully. Thanks for replying, good luck.