NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.44k stars 13.64k forks source link

Haxe + OpenFl Could not initialize SDL: No available video device. #40964

Open desttinghim opened 6 years ago

desttinghim commented 6 years ago

Issue description

I am trying to do some basic development work with Haxe and OpenFl. I can get OpenFl projects and samples to compile, but I can't get them to run. I get this error:

Could not initialize SDL: No available video device.
Could not create SDL window: No available video device.
Could not create SDL renderer: Invalid window.

I asked about this on the OpenFl forums. I found I didn't quite have all the libraries installed, so I installed them. The libraries in question are libX11, libXext, libXinerama, libXi and libxrandr. Installing these libraries did not seem to help.

I then asked on the #nixos irc channel and was guided to set LD_DEBUG=libs in the environment. This was the output.

Looking at the printout, it looks like ld is unable to find the libraries I had installed, and it looked in the wrong places. I am not sure how to coerce ld into looking for the libraries in the correct locations.

Steps to reproduce

nix-env -iA nixos.haxe
haxelib install openfl
haxelib run openfl setup
haxelib run openfl create HelloTriangle
haxelib run openfl test linux

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.40, NixOS, 18.03.132336.ef74cafd3e5 (Impala)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.1`
 - channels(root): `"nixos-18.03.132336.ef74cafd3e5, nixos-unstable-18.09pre140099.f53d22edd68"`
 - channels(desttinghim): `"nixpkgs-18.09pre140705.090b7cc8f1b, nixos-18.03-18.03.132405.ee80654b526"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`
katyo commented 4 years ago

This works for me with default.nix below:

{ pkgs ? import <nixpkgs> {} }:
with pkgs;
stdenv.mkDerivation {
  name = "haxeapp";

  # export paths to be able to run tests
  LD_LIBRARY_PATH = with xorg; "${libX11}/lib:${libXext}/lib:${libXinerama}/lib:${libXi}/lib:${libXrandr}/lib:${libglvnd}/lib";

  buildInputs = [ stdenv pkgconfig libglvnd ] ++
    (with xorg; [ libX11 libXext libXinerama libXi libXrandr ]);
}

As an option you can simply run nix-shell to test it:

$ nix-shell
$ haxelib run openfl test linux

Of course, you should use wrapProgram for executables to create final nix derivations (packages).

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
crowplexus commented 6 months ago

same issue here (6 years later wow), hoping to see a fix for this soon

Link: ApplicationMain
AL lib: (EE) ALCplaybackOSS_open: Could not open /dev/dsp: No such file or directory
Could not initialize SDL: No available video device.
Could not create SDL window: No available video device.