1

I am following these instructions to run my .NET 6 console app on my Raspberry Pi and the last point (4.b) is causing me some troubles.

After deploying my app to the raspberry pi, I am running the following commands:

pi@babyminder:~/babyminder $ chmod +x PoC.BabyMinder.Gpio
pi@babyminder:~/babyminder $ ls -l
total 18668
-rw-r--r-- 1 pi pi     9824 Jul 19 23:09 libSystem.IO.Ports.Native.so
-rwxr-xr-x 1 pi pi 19089322 Jul 19 23:09 PoC.BabyMinder.Gpio
-rw-r--r-- 1 pi pi    10892 Jul 19 23:09 PoC.BabyMinder.Gpio.pdb
pi@babyminder:~/babyminder $ ./PoC.BabyMinder.Gpio
-bash: ./PoC.BabyMinder.Gpio: No such file or directory

Here is the content of my pubxml file:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>bin\Release\net6.0\publish\linux-arm\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifier>linux-arm</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishTrimmed>true</PublishTrimmed>
  </PropertyGroup>
</Project>

Here is the scp command I used:

scp -r bin/Release/net6.0/publish/linux-arm/* pi@babyminder:/home/pi/babyminder/

I don't understand what is going wrong with my setting?

Here are some additional information:

  • I only know the very basic of unix
  • My Raspberry Pi is a fresh installation of Raspberry Pi OS Lite (64 bits)
  • chmod 777 does not work either
  • If I omit the chmod command, I get the following error when I try to execute the file: -bash: ./PoC.BabyMinder.Gpio: Permission denied (so the file does exist)
  • Looks like the answer is here but I honestly do not understand everything ...
  • Deploying a framework-dependent app works like a charm (previous paragraph in the first link provided)
fharreau
  • 2,105
  • 1
  • 23
  • 46
  • What does `file` report your program is? Is it different than a program that works (e.g., `file /bin/bash`)? – Stephen Newell Jul 19 '22 at 21:49
  • @StephenNewell : I am sorry I do not understand the question. You can consider me a very beginner in all this unix stuff ... – fharreau Jul 19 '22 at 21:51
  • @StephenNewell I found out. The command `file` does not exists on my raspberry : `$ file PoC.BabyMinder.Gpio -bash: file: command not found` – fharreau Jul 19 '22 at 22:00
  • I ran `ldd` as suggested in the link I provided in the end of my post: `$ ldd PoC.BabyMinder.Gpio not a dynamic executable`. As suspected, it looks like a cross-compile failure. But I don't know how to fix it with `.NET6` – fharreau Jul 19 '22 at 22:02
  • Could it be because I installed an arm64 OS and the dotnet SDK only supports arm32? – fharreau Jul 19 '22 at 22:18

2 Answers2

0

I re-installed a 32 bit OS and it works now ...

According to this link, I guess the .NET SDK is providing some wrong arguments to the cross-compiler (I am a little bit out of my field here so I'm only guessing ^^).

fharreau
  • 2,105
  • 1
  • 23
  • 46
0

Make sure you select the correct compiler for your Raspberry Pi. For a 32bit installation, use linux-arm and for a 64bit installation use linux-arm64.

You can also check to see if you compiled correctly by running ldd <MyApplication> from the shell on your Raspberry Pi. A properly compiled file will give you output that looks like this:

pi@raspberrypi:/var/services/ $ ldd MyApplication
        linux-vdso.so.1 (0x0000007fb7bba000)
        libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fb7185000)
        libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fb7171000)
        libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000007fb7147000)
        librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000007fb712f000)
        libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000007fb710b000)
        libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000007fb6f33000)
        libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fb6e88000)
        libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fb6d13000)
        /lib/ld-linux-aarch64.so.1 (0x0000007fb7b8a000)

Whereas incorrectly compiled files will say not a dynamic executable

Chris Stillwell
  • 10,266
  • 10
  • 67
  • 77