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.56k stars 102 forks source link

Cannot run Sokol sample on Linux (Ubuntu 22.04 WSL2) #140

Closed lucabol closed 5 months ago

lucabol commented 5 months ago

It is looking for sokol.so, not sure where to get it. I thought sokol was an header only library ... tried web searching for it, but nothing. Perhaps I am missing something obvious?

λ  ./triangle
Unhandled Exception: System.DllNotFoundException: Unable to load shared library 'sokol' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
sokol.so: cannot open shared object file: No such file or directory
libsokol.so: cannot open shared object file: No such file or directory
sokol: cannot open shared object file: No such file or directory
libsokol: cannot open shared object file: No such file or directory

   at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x46
   at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell*) + 0x127
   at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell*) + 0x35
   at Sokol.App.Run(App.Desc&) + 0x6b
   at Program.<Main>$(String[] args) + 0xa3
   at triangle!<BaseAddress>+0x1449dc
Aborted
MichalStrehovsky commented 5 months ago

The sokol repo is linked from https://github.com/bflattened/bflat/tree/master/samples/Sokol - https://github.com/MichalStrehovsky/sokol-csharp. I haven't made a linux build of the native library. I'm not sure if I really want to keep it as built-in part of bflat, it's a hassle to maintain the binaries.

lucabol commented 5 months ago

Yeah, I was surprised you would do that. I would consider using sokol as an example of how you can use an header only C/C++ library from bflat as there are many header only ones these days ...

lucabol commented 5 months ago

Sorry, looking at the sample source, my suggestion doesn't make sense as you are using a C# wrapper already. So it's not an example of using an header only lib anyhow.

MichalStrehovsky commented 5 months ago

Yeah, bflat is not a C compiler, so this needs to be compiled separately and some kind of p/invoke wrapper generated. I've used a python-based generator that the sokol repo uses. Would be nice to be able to just #include it like CGO. Maybe some day, but CGO is also where building Go starts to be hard.

lucabol commented 5 months ago

Yep. Closing the issue. BTW: what's the best way to ask you questions about this project? I am curious about the zero (is it different than none stdlib? Also which kinds of pinvoke can be done in 'zero'/'none'?

MichalStrehovsky commented 5 months ago

Either open an issue or a discussion in this repo.

Zero at least defines things like system.object. None is really only useful you vendor in zero's source code. The compiler crashes spectacularly if things are missing.

Pinvoke support is limited to things that work without marshalling, so most primitive types, structs of those, or pointers