Search code examples
c#.net-corearmopenwrtmusl

Compiling dotnet core app for linux-musl-arm


I tried compiling a simple .NET Core hello world app for OpenWRT on ARM Cortex A7 using linux-musl-arm with the following command:

dotnet publish --configuration Release --runtime linux-musl-arm --self-contained

But i get the following error when i try to execute it:

root@Routeur:~/RutxApp# ./RutxApp
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_assignERKS4_: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEjjPKcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEjjPKcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEcj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12find_last_ofEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE14_M_replace_auxEjjjc: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode: symbol not found
Error relocating ./RutxApp: _ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17find_first_not_ofEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating ./RutxApp: __time64: symbol not found
Error relocating ./RutxApp: __gmtime64: symbol not found
Error relocating ./RutxApp: __fstat_time64: symbol not found
Error relocating ./RutxApp: __dlsym_time64: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEjjRKS4_: symbol not found
Error relocating ./RutxApp: __fstatat_time64: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEjjPKc: symbol not found
Error relocating ./RutxApp: _ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE: symbol not found
Error relocating ./RutxApp: _ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE: symbol not found

I followed this tutorial : https://davidjmclaughlin.com/projects/how-to/2020/03/15/running-.net-core-on-openwrt-and-raspberry-pi-4.html and installed all required library but without success.

I'm trying to run this code on a RUTX11 from Teltonika


EDIT 1:

When i execute ldd ./RutxApp i get the following messages:

root@Routeur_VIGICAM:~/RutxApp# ldd ./RutxApp
        /lib/ld-musl-armhf.so.1 (0xb6ed6000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb6e0e000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb6df2000)
        libc.musl-armv7.so.1 => /lib/ld-musl-armhf.so.1 (0xb6ed6000)
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_assignERKS4_: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEjjPKcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_mutateEjjPKcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5rfindEcj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12find_last_ofEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE8_M_eraseEjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE14_M_replace_auxEjjjc: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEcj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode: symbol not found
Error relocating ./RutxApp: _ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE17find_first_not_ofEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEj: symbol not found
Error relocating ./RutxApp: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating ./RutxApp: __time64: symbol not found
Error relocating ./RutxApp: __gmtime64: symbol not found
Error relocating ./RutxApp: __fstat_time64: symbol not found
Error relocating ./RutxApp: __dlsym_time64: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4findEPKcjj: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEjjRKS4_: symbol not found
Error relocating ./RutxApp: __fstatat_time64: symbol not found
Error relocating ./RutxApp: _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEjjPKc: symbol not found
Error relocating ./RutxApp: _ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE: symbol not found
Error relocating ./RutxApp: _ZTVNSt7__cxx1115basic_stringbufIcSt11char_traitsIcESaIcEEE: symbol not found
root@Routeur_VIGICAM:~/RutxApp#

I don't know what i'm missing...


EDIT 2:

Ok thanks to @albirew answer it look like the musl version mismatch... I tried to downgrade the .NET Core version to a version that use musl with x86 libc libraries (netcoreapp3.1) but now the app try to load ld-linux-armhf.so but it doesn't exist in the system, instead there is ld-musl-armf.so (this was loaded with next version version of .NET Core)

Wrong library loaded

Note: it's the same error when i compile with linux-arm runtime (instead of linux-musl-arm)

More informations about OpenWrt version 21.02.0:

OpenWrt version


Solution

  • Like I said, this is a version mismatch between the runtimes build against vs run against.

    hnyman explained it on openwrt forums that seeing the __time64: symbol not found error made him believe you are building your app using musl 1.2.2+ with x64 time symbols, but the Teltonika router is using OpenWrt 21.02.x with the older musl 1.1.24 version and x86 time handling.