1

I'm creating a C# app which I have build or as they call it "published" for linux-x64 following this XML in the csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <Configuration>release</Configuration>
    <InvariantGlobalization>true</InvariantGlobalization>
    <TargetFramework>net5.0</TargetFramework>
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="mongocsharpdriver" Version="2.11.6" />
    <PackageReference Include="MongoDB.Bson" Version="2.11.6" />
    <PackageReference Include="MongoDB.Driver" Version="2.11.6" />
    <PackageReference Include="MongoDB.Driver.Core" Version="2.11.6" />
    <PackageReference Include="PCSC" Version="5.0.0" />
    <PackageReference Include="PCSC.Iso7816" Version="5.0.0" />
  </ItemGroup>

</Project>

I'm on Linux Ubuntu 20.04 .

I published the application using CLI to the folder bin/release etc etc. It ran just fine when I tested it. Now, for the main branch, I deleted all code. Moved the directory release up in the main directory, and pushed it to GIT.

Whenever you try to run it now, it gives the following error:

./Appname: relocation error: ./Appname: symbol pthread_attr_init version GLIBC_2.2.5 not defined in file libpthread.so.0 with link time reference

As I'm not a native C# developer and still learning, I have absolutely no idea what this is about, except it apparently has something to do with me moving the directory (I quess?)

Does anyone know what this error is or where it comes from, how to fix it, and how to prevent in the future? As I would like to be able to publish an application without errors.

solved

I Found the answer. There is another directory within the build directory called "publish" which contains the working executable. In other words. The exe is in the folder release/net5.0/linux-x64/publish instead of release/net5.0/linux-x64. When I run the executable from that directory, everything works just fine. For other newbies: It is in the folder release because my XML project file has a Configuration field set to release. It is in the folder Debug by default. i'm an idiot

Oscar K
  • 185
  • 1
  • 11
  • 1
    I don't have an answer sadly, but some comments. `relocation error` is generally an error from the run time linker (the linux component that resolves dependencies to all native libraries on the system). It looks like the generated executable has a dependency on `pthread_attr_init` provided by `libpthread.so.0` but that's not there... Do you get the error if you disable trimming? What about if you disable single file? Do you get the error with a Hello-World style project without any nuget dependencies on PCSC or Mongo? – omajid Jun 11 '21 at 21:59
  • 1
    It sounds like that function moved from `libpthread.so.0` to `librt.so.1`. You should see `eu-readelf -a /usr/lib64/libpthread.so.0 | grep pthread_attr_init` return nothing and `eu-readelf -a /usr/lib64/librt.so.1 | grep pthread_attr_init` show a `FUNC GLOBAL DEFAULT` function. Err, use the correct paths for your OS (I am running Fedora here). So, it sounds like something (.NET? Mongo? PCSC?) needs an update to work with Ubuntu 20.04. – omajid Jun 11 '21 at 22:03
  • I'm gonna test a hello world application and will get back to you. Thanks. – Oscar K Jun 14 '21 at 07:59
  • It works in my publish folder too, but when I move the executable and run it outside of the publish folder, I get that same exact relocation error. – OCDev Oct 29 '21 at 07:46

0 Answers0