boybanyas
Posts: 5
Joined: Mon Mar 19, 2018 10:52 am

C# WiringPi - unable to load libwiringPi.so

Mon Mar 19, 2018 11:29 am

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.
Attachments
libwiringPi_error.png
libwiringPi_error.png (58.08 KiB) Viewed 1240 times

Patm
Posts: 23
Joined: Thu Mar 22, 2018 3:19 am

Re: C# WiringPi - unable to load libwiringPi.so

Thu Mar 22, 2018 3:44 am

First question - did you install wiringpi?

boybanyas
Posts: 5
Joined: Mon Mar 19, 2018 10:52 am

Re: C# WiringPi - unable to load libwiringPi.so

Thu Mar 22, 2018 7:12 am

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?

Patm
Posts: 23
Joined: Thu Mar 22, 2018 3:19 am

Re: C# WiringPi - unable to load libwiringPi.so

Fri Mar 23, 2018 11:57 pm

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.

Patm
Posts: 23
Joined: Thu Mar 22, 2018 3:19 am

Re: C# WiringPi - unable to load libwiringPi.so

Sat Mar 24, 2018 12:44 pm

Just had a thought, are you running the program locally on your PC or from the command line on your Pi?

boybanyas
Posts: 5
Joined: Mon Mar 19, 2018 10:52 am

Re: C# WiringPi - unable to load libwiringPi.so

Sat Mar 24, 2018 11:34 pm

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?
Last edited by boybanyas on Sun Mar 25, 2018 4:51 am, edited 1 time in total.

boybanyas
Posts: 5
Joined: Mon Mar 19, 2018 10:52 am

Re: C# WiringPi - unable to load libwiringPi.so

Sun Mar 25, 2018 1:38 am

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.

Patm
Posts: 23
Joined: Thu Mar 22, 2018 3:19 am

Re: C# WiringPi - unable to load libwiringPi.so

Sun Mar 25, 2018 2:47 pm

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.

boybanyas
Posts: 5
Joined: Mon Mar 19, 2018 10:52 am

Re: C# WiringPi - unable to load libwiringPi.so

Tue Mar 27, 2018 3:50 pm

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.

Return to “Other programming languages”

Who is online

Users browsing this forum: No registered users and 4 guests