Araq / pixels

Toy support library for primitive graphics programming.
MIT License
12 stars 6 forks source link

Implicit dependencies : sdl2 and sdl2_ttf #7

Open dlesnoff opened 2 years ago

dlesnoff commented 2 years ago

On Archlinux 5.18.14-zen1-1-zen, I need to install sdl2_ttf, otherwise I get a runtime error.

could not load: libSDL2_ttf(|-2.0).so(|.0) (compile with -d:nimDebugDlOpen for more information) Error: execution of an external program failed: '/home/kolmogorov/Documents/dev/mastering_nim/src/chapter1 '

I added import sdl2 on top of the first script of mastering nim example, and downloaded sdl2_ttf via pacman: sudo pacman -S sdl2_ttf I had also installed sdl2 nim package through nimble. I solved my problem by this installation of sdl2_ttf. The dependency sdl2_ttf should be added to pixels.nimble.

trev-dev commented 1 year ago

I'm also following along with the book, but even worse yet: on a nixos system.

libSDL2.so: cannot open shared object file: No such file or directory
could not load: libSDL2.so

I tried using nix-shell -p SDL but of course the binary can never expect to find things in "standard places" on a nix or nix-like system.

dlesnoff commented 1 year ago

Do you know where the library is located on your Nix configuration?

trev-dev commented 1 year ago

It depends on how you want to find it. Generally speaking things get symlinked pretty reliably to ~/.nix-profile/lib - I can see libSDL2.so sitting there. If you somehow use nix to generate a conf or env, you can get the explicit store link.

danlexo commented 1 year ago

Nim: 1.6.8 x86_64

could not load: SDL2_ttf.dll
(bad format; library may be wrong architecture)

Solution: Download the latest x64 version of SDL2 and _SDL2tff

trev-dev commented 1 year ago

I managed to get my compile of this chapter to run but it is key that the libraries be installed at compile time. After they are installed, compile and run it.

After that, hope that your font is installed in /usr/share/fonts (mine is not) because there appears to be some hard-coding there, but I do get a nice black square rendered.

dlesnoff commented 1 year ago

Your font must be a .ttf

it is key that the libraries be installed at compile time.

The library must be installed before you compile your Nim program. It does not make sense to me to say that a library is installed at compile time.

trev-dev commented 1 year ago

It does not make sense to me to say that a library is installed at compile time.

I say this because pixels compiles without the dependencies installed and the dependency error gets thrown at runtime.

Here i went, down a rabbit hole, to install missing runtime dependencies and yet the program would still not run.

I am a novice when it comes to compiling C programs but I felt this difference was important. If that was already a given I apologize.

maikelthedev commented 9 months ago

I'm also following along with the book, but even worse yet: on a nixos system.

libSDL2.so: cannot open shared object file: No such file or directory
could not load: libSDL2.so

I tried using nix-shell -p SDL but of course the binary can never expect to find things in "standard places" on a nix or nix-like system.

same, somehow it works with nix-shell but not with the system having the rquired libraries.

So if I run a

nim c -r something.nim

it fails with the message above butt if I run it with

nix-shell -p nim SDL2 SDL2_ttf SDL2_image
# then
nim c -r something.nim

it works. All those libraries are part of system.

dlesnoff commented 8 months ago

That's more an issue with Nix and the system libraries a priori. Have you tried setting up the LD_LIBRARY_PATH?

trev-dev commented 8 months ago

That's more an issue with Nix and the system libraries a priori. Have you tried setting up the LD_LIBRARY_PATH?

Nix is one of two useful linux distros that do not adhere the FHS (Filesystem Hierarchy Standard). But these libs are required for pixels to work. Libs are not guaranteed to be there on compliant root systems anyway. I think if portability is not a chief concern here, then we should document all that is required.

I am happy to do the work.

Araq commented 8 months ago

I am happy to do the work.

I am happy to review and merge PRs. As always.