bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)
GNU Affero General Public License v3.0
3.66k stars 107 forks source link

Cannot find objwriter.so in Version 8.0.2 #203

Closed pracsec closed 3 months ago

pracsec commented 3 months ago

I receive the following error when running the command below with the bflat-8.0.2-linux-glibc-x64 release version.

Command:

./bflat build /home/kali/test/program.cs --target WinExe --arch x64 --out /home/kali/test/program.exe

Error:

Error: DllNotFound_Linux, objwriter,
objwriter.so: cannot open shared object file: No such file or directory
libc++.so.1: cannot open shared object file: No such file or directory
objwriter: cannot open shared object file: No such file or directory
libobjwriter: cannot open shared object file: No such file or directory

System.DllNotFoundException: DllNotFound_Linux, objwriter,
objwriter.so: cannot open shared object file: No such file or directory
libc++.so.1: cannot open shared object file: No such file or directory
objwriter: cannot open shared object file: No such file or directory
libobjwriter: cannot open shared object file: No such file or directory

   at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x47
   at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell*) + 0x127
   at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell*) + 0x35
   at ILCompiler.DependencyAnalysis.ObjectWriter.InitObjWriter(String, String) + 0x43
   at ILCompiler.DependencyAnalysis.ObjectWriter..ctor(String, NodeFactory, ObjectWritingOptions) + 0x19a
   at ILCompiler.DependencyAnalysis.ObjectWriter.EmitObject(String, IReadOnlyCollection`1, NodeFactory, ObjectWritingOptions, IObjectDumper, Logger) + 0x85
   at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String, ObjectDumper) + 0x32
   at BuildCommand.Handle(ParseResult) + 0x2fef
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext() + 0x139
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext() + 0xf2
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext() + 0xbf
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseVersionOption>b__0>d.MoveNext() + 0x1dd
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xbe
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x4e
   at System.CommandLine.Invocation.InvocationPipeline.<Invoke>g__FullInvocationChain|3_0(InvocationContext) + 0x8a
   at Program.Main(String[] args) + 0x2b4
pracsec commented 3 months ago

Follow-up: ok, so I found a work-around by installing the libc++-dev package using the command below. That seems to provide all of the requisite binaries needed to complete the compilation.

I would like to not have to install additional dependencies to make bflat work though, or if I do, then I would like to see it listed in the installation instructions.

apt-get install libc++-dev
MichalStrehovsky commented 3 months ago

This was already "fixed" in upstream by deleting objwriter.so and replacing it with a C# implementation. bflat 9.0 won't have this dependency (and problem) anymore.

pracsec commented 3 months ago

Awesome! I also found an easier work-around. Just copy "libc++.so.1" from lib64 to the root folder. That fixed my issue without requiring libc++-dev.

Fantastic project BTW!