Hi,
This may be a simple problem, it's giving me headache for days already. Hope you could help out.
I have a working C# program using WiringPi last year. I'm using Visual Studio 2015.
Now I want to use it again, but it produces this error:
"Unable to load DLL 'libwiringPi.so'.
I'm using danriches WiringPi.net
Please see attach image file.
Thank you.
C# WiringPi - unable to load libwiringPi.so
- Attachments
-
- libwiringPi_error.png (58.08 KiB) Viewed 8349 times
Re: C# WiringPi - unable to load libwiringPi.so
First question - did you install wiringpi?
Re: C# WiringPi - unable to load libwiringPi.so
Hi Patm,
Thanks for your response.
I followed https://gitlearning.wordpress.com/2016/ ... ts-with-c/
I build WiringPi wrapper class in Visual Studio, then add WiringPi.dll in references of my form.
If in case I miss something, can you please guide me. I forgot how I made it work last year.
What should be done to install libwiringPi.so in Visual Studio 2017?
Thanks for your response.
I followed https://gitlearning.wordpress.com/2016/ ... ts-with-c/
I build WiringPi wrapper class in Visual Studio, then add WiringPi.dll in references of my form.
If in case I miss something, can you please guide me. I forgot how I made it work last year.
What should be done to install libwiringPi.so in Visual Studio 2017?
Re: C# WiringPi - unable to load libwiringPi.so
Well I was just trying it out. The default package doesn't seem to even have a libwiringPi.o so I removed it and cloned wiringPi's git repository according to their instructions at http://wiringpi.com/download-and-install/
From there I went into the wiringPi directory and found all the .o files and, cc'd as per instructions (just the first one - the other two are no longer necessary apparently).
From there I compiled the wiringPi.net solution and copied the .exe and .dll to the pi and it didn't complain.
From there I went into the wiringPi directory and found all the .o files and, cc'd as per instructions (just the first one - the other two are no longer necessary apparently).
From there I compiled the wiringPi.net solution and copied the .exe and .dll to the pi and it didn't complain.
Re: C# WiringPi - unable to load libwiringPi.so
Just had a thought, are you running the program locally on your PC or from the command line on your Pi?
Re: C# WiringPi - unable to load libwiringPi.so
I'm currently developing the program from my PC (windows 10) using Visual Studio 2017.
Once I'm done, i will transfer the compiled exe program to the Raspberry pi.
I'm still on the first stage, I can't compile on VS because it cannot locate libwiringPi.so.
I will clone wiringPi's git repository using Raspberry Pi, get the libwiringPi.so and transfer (using filezilla) it to the /WiringPi/bin/debug folder on my PC.
Is this procedure correct?
Once I'm done, i will transfer the compiled exe program to the Raspberry pi.
I'm still on the first stage, I can't compile on VS because it cannot locate libwiringPi.so.
I will clone wiringPi's git repository using Raspberry Pi, get the libwiringPi.so and transfer (using filezilla) it to the /WiringPi/bin/debug folder on my PC.
Is this procedure correct?
Last edited by boybanyas on Sun Mar 25, 2018 4:51 am, edited 1 time in total.
Re: C# WiringPi - unable to load libwiringPi.so
On raspberry, I did "cc -shared wiringPi.o -o libwiringPi.so" to create the libwiringPi.so.
Then transfer the created libwiringPi.so to C:windows/system32 folder.
No more unable to load libwiringPi.so error, but System.BadImageFormatException occurred. An attempt was made to load a program with an incorrect format.
Then transfer the created libwiringPi.so to C:windows/system32 folder.
No more unable to load libwiringPi.so error, but System.BadImageFormatException occurred. An attempt was made to load a program with an incorrect format.
Re: C# WiringPi - unable to load libwiringPi.so
I don't have wiringPi on the PC, don't think it exists except as a fake that gives you the ability to compile but the functions would be all empty.
What I did was create a samba share on the Pi and put the project there. I only load the project from the Pi. I can then use build (running doesn't work on the PC even if there's no errors since it doesn't have the devices) and run the binary with "mono my.exe:.
I then downloaded MonoRemoteDebugger and unzipped it to my Pi home directory and run that from a second CLI. Next get the MonoRemoteDebugger plugin for VS (2015 or 2017) and install that.
From there I can just choose the MonoRemoteDebugger->Debug Remote and it'll run on the Pi while reporting debug information on the PC. Just keep in mind you won't see build errors so run build from the PC (though the project you've got loaded is on the Pi) and once that's good do a Remote Debug.
Oh and if you mono my.exe it'll dump a stack trace into the CLI too - sometimes the debug information getting to the PC doesn't tell you enough.
What I did was create a samba share on the Pi and put the project there. I only load the project from the Pi. I can then use build (running doesn't work on the PC even if there's no errors since it doesn't have the devices) and run the binary with "mono my.exe:.
I then downloaded MonoRemoteDebugger and unzipped it to my Pi home directory and run that from a second CLI. Next get the MonoRemoteDebugger plugin for VS (2015 or 2017) and install that.
From there I can just choose the MonoRemoteDebugger->Debug Remote and it'll run on the Pi while reporting debug information on the PC. Just keep in mind you won't see build errors so run build from the PC (though the project you've got loaded is on the Pi) and once that's good do a Remote Debug.
Oh and if you mono my.exe it'll dump a stack trace into the CLI too - sometimes the debug information getting to the PC doesn't tell you enough.
Re: C# WiringPi - unable to load libwiringPi.so
Thanks Patm for the suggestions.
I remember before that I program directly on Visual Studio C#, then transfer the Release folder to the Raspberry Pi wherein I will execute it using Mono.
Maybe there are plugins I'm missing or need tweaks on the updated wiringPi.
I remember before that I program directly on Visual Studio C#, then transfer the Release folder to the Raspberry Pi wherein I will execute it using Mono.
Maybe there are plugins I'm missing or need tweaks on the updated wiringPi.
Re: C# WiringPi - unable to load libwiringPi.so
Hi There boybanyas,
Did you resolve this problem?
Because at the moment I am stuck with exactly the same problem as yours.
Would appreciate it if you have time to response.
Thanks and regards,
Marc
Did you resolve this problem?
Because at the moment I am stuck with exactly the same problem as yours.
Would appreciate it if you have time to response.
Thanks and regards,
Marc
Re: C# WiringPi - unable to load libwiringPi.so
I'm working in C# too, but on NetCore 2.2 and I find Unosquare wrapper around the wiringPi lib working very nice.
https://github.com/unosquare/raspberryio
https://github.com/unosquare/raspberryio
Re: C# WiringPi - unable to load libwiringPi.so
I'm confused. Is the OP talking about developing a C# .NET Framework app for Raspberry Pi? I don't think that'll work. You can do .NET Core, but you can't do .NET Framework.
Furthermore, if you're linking to wiringPi.so, you won't be able to build in windows. BadImageFormat because .so files aren't a recognized windows image format. Unfortunately, as far as I can tell, you can't actually build for arm in VS2017.
You'll need to switch to .net core (2.2 is just dandy) and you'll need to actually build on the Pi.
To make things easier, you can create your initial project and do the development in vs.net and copy it over with some minor changes. I haven't run into your issue because I'm not linking external libraries, so I can develop and compile in Windows and then just copy to the pi to rebuild.
You can download the sdk and runtime here:
https://dotnet.microsoft.com/download/t ... 2-binaries
https://dotnet.microsoft.com/download/t ... 2-binaries
(both from this page: https://dotnet.microsoft.com/download/dotnet-core/2.2)
Furthermore, if you're linking to wiringPi.so, you won't be able to build in windows. BadImageFormat because .so files aren't a recognized windows image format. Unfortunately, as far as I can tell, you can't actually build for arm in VS2017.
You'll need to switch to .net core (2.2 is just dandy) and you'll need to actually build on the Pi.
To make things easier, you can create your initial project and do the development in vs.net and copy it over with some minor changes. I haven't run into your issue because I'm not linking external libraries, so I can develop and compile in Windows and then just copy to the pi to rebuild.
You can download the sdk and runtime here:
https://dotnet.microsoft.com/download/t ... 2-binaries
https://dotnet.microsoft.com/download/t ... 2-binaries
(both from this page: https://dotnet.microsoft.com/download/dotnet-core/2.2)
Re: C# WiringPi - unable to load libwiringPi.so
I am trying to develop a GUI app to run on the Pi, and I would like to do it with Visual Studio. Can some please summarize the steps to do this?
I have successfully run the Blink project in Visual Studio 2109, and experimented with modifying it (like adding LED's etc.). But it doesn't have GUI (Forms) capability and I can't figure out how to add forms to that project.
I created a Forms app in Visual Studio with Mono, and it runs on the Pi. But I can't figure out how to use WiringPi with that project.
I have quite a bit of experience with Visual Basic in Visual Studio, but the app I want to do for the Pi is not complex so I think I can figure out how to do it with C if necessary, if I could figure out how to make a Forms app that can access the Pi GPIO with WiringPi (or whatever).
Any guidance would be greatly appreciated.
I have successfully run the Blink project in Visual Studio 2109, and experimented with modifying it (like adding LED's etc.). But it doesn't have GUI (Forms) capability and I can't figure out how to add forms to that project.
I created a Forms app in Visual Studio with Mono, and it runs on the Pi. But I can't figure out how to use WiringPi with that project.
I have quite a bit of experience with Visual Basic in Visual Studio, but the app I want to do for the Pi is not complex so I think I can figure out how to do it with C if necessary, if I could figure out how to make a Forms app that can access the Pi GPIO with WiringPi (or whatever).
Any guidance would be greatly appreciated.
- DougieLawson
- Posts: 40594
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: C# WiringPi - unable to load libwiringPi.so
A few problems here
1. http://wiringpi.com/wiringpi-deprecated/
2. C# isn't well supported on this forum because nobody can get it to work with things like WiringPi
3. The user base for mono is miniscule - try asking on the https://www.mono-project.com/community/ forums
What's stopping you using python with pigpio / pigpiod?
Have you looked at pigpiod's TCP/IP socket interface you could drive that from Mono?
Or switching to C/C++? [Don't choose Java as it has exactly the same problems as Mono.]
1. http://wiringpi.com/wiringpi-deprecated/
2. C# isn't well supported on this forum because nobody can get it to work with things like WiringPi
3. The user base for mono is miniscule - try asking on the https://www.mono-project.com/community/ forums
What's stopping you using python with pigpio / pigpiod?
Have you looked at pigpiod's TCP/IP socket interface you could drive that from Mono?
Or switching to C/C++? [Don't choose Java as it has exactly the same problems as Mono.]
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
- RichardRussell
- Posts: 701
- Joined: Thu Jun 21, 2012 10:48 am
Re: C# WiringPi - unable to load libwiringPi.so
Or even BBC BASIC with the gpiolib library?!DougieLawson wrote: ↑Thu Apr 02, 2020 9:54 amWhat's stopping you using python with pigpio / pigpiod?

- DougieLawson
- Posts: 40594
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: C# WiringPi - unable to load libwiringPi.so
I wouldn't have known that, it's a language I don't have any desire to use.RichardRussell wrote: ↑Thu Apr 02, 2020 5:14 pmOr even BBC BASIC with the gpiolib library?!DougieLawson wrote: ↑Thu Apr 02, 2020 9:54 amWhat's stopping you using python with pigpio / pigpiod?![]()
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
- RamaSpaceShip
- Posts: 150
- Joined: Sun Apr 26, 2020 12:19 pm
Re: C# WiringPi - unable to load libwiringPi.so
I use wiringpi in C# since two years without trouble. I use the wrapper class written by Daniel J Riches.DougieLawson wrote: ↑Thu Apr 02, 2020 9:54 am2. C# isn't well supported on this forum because nobody can get it to work with things like WiringPi
I have a Pi4 with a SSD for compiling purposes to avoid issues like the one described here.
And I use Monodevelop from a Debian Amd64 machine to do the development and testing, eventually remote.
.I don't use Visual Studio (nor Windows) so I cannot tell you much about these.
But you can create a class with the same name and methods than the wrapper that implements a simulation of the WiringPi actions for Windows. This will allow you to test on Windows. And when on the Pi, you use the wrapper.