Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fltkhs-0.2.0.0 does not compile because of undeclared dependencies #16

Closed
peti opened this issue Oct 9, 2015 · 22 comments · Fixed by NixOS/cabal2nix#326
Closed

fltkhs-0.2.0.0 does not compile because of undeclared dependencies #16

peti opened this issue Oct 9, 2015 · 22 comments · Fixed by NixOS/cabal2nix#326

Comments

@peti
Copy link

peti commented Oct 9, 2015

The fltkhs-0.2.0.0 build depends on fltk-config (or rather: the system package that provides this tool), but this dependency is not declared in the Cabal file, hence NixOS will not provide that package in the build environment, causing the build to fail. Also, the build seems to depend on autoconf (why?), which is also not declared.

@peti
Copy link
Author

peti commented Oct 9, 2015

Another undeclared system dependency is on the GL/gl.h header file.

@peti
Copy link
Author

peti commented Oct 9, 2015

Last but not least, the build tries to link -ljpeg -- which is not declared as a dependency. I also wonder why the autoconf script doesn't detect the absence of the library and aborts with an error.

@peti
Copy link
Author

peti commented Oct 9, 2015

Finally, after all those issues have been fixed, I run into lots and lots of link errors, complaining about missing symbols like gl_start(), probably because the OpenGL libraries aren't linked.

@deech
Copy link
Owner

deech commented Oct 9, 2015

Hi,
Thanks for the report!

There are two build systems in the project, a Make based one for building the C++ bindings and a Cabal one for Haskell. autoconf is required to create a configure script that checks dependencies etc. Setup.hs first runs autoconf, configure and then make before building the Haskell side of things.

With regards to your specific issues:

It sounds like if you're having all these problems the configure and Make part of the build are not running.

What happens if you just try and install in the traditional way outside of a NixOS environment?

@peti
Copy link
Author

peti commented Oct 9, 2015

fltk-config is declared as a dependency here (https://github.com/deech/fltkhs/blob/master/configure.ac#L10).

Checking for the existence of fltk-config in the configure script is not the same thing as adding a build-tools: fltk-config stanza to the Cabal file. Nix generates a minimal build environment in a chroot hierarchy that contains only those build inputs that the Cabal specifies as required. Since fltkhs doesn't mention any of those packages, they aren't available to the build, so it doesn't matter much what the configure script does.

It sounds like if you're having all these problems the configure and Make part of the build are not running.

No, the configure/make part of the build runs. See http://pastebin.com/b1iqmL1L for a complete build log.

What happens if you just try and install in the traditional way outside of a NixOS environment?

I don't know. Since I work on NixOS only, I can't easily run these builds outside of a NixOS environment.

@cstrahan
Copy link

Hi, I'd like to play with fltkhs at Compose conference. Would it be possible to resolve this issue before then? Thanks!

@deech
Copy link
Owner

deech commented Jan 24, 2016

I can try. I'll add those libraries to the Cabal file but I know nothing about Nix. If I start a branch, are you able to test for me?

@cstrahan
Copy link

cstrahan commented Feb 3, 2016

@deech Hey, sorry - I lost track of your reply. Yeah, I can test it out for you.

@cstrahan
Copy link

cstrahan commented Feb 3, 2016

Just tried building again. Here's the updated log: http://sprunge.us/Njgf

@cstrahan
Copy link

cstrahan commented Feb 3, 2016

(That was with version 0.4.0.0)

@cstrahan
Copy link

cstrahan commented Feb 3, 2016

If it helps, here's the fltkhs.buildinfo:

ld-options: /nix/store/n9gi42gycxp66grqcnq3zdarfn4kvpym-fltk-1.3.3/lib/libfltk_images.a -lpng -lz -ljpeg /nix/store/n9gi42gycxp66grqcnq3zdarfn4kvpym-fltk-1.3.3/lib/libfltk_forms.a /nix/store/n9gi42gycxp66grqcnq3zdarfn4kvpym-fltk-1.3.3/lib/libfltk.a -lpthread -ldl -lm -lX11 -lstdc++
include-dirs: /nix/store/n9gi42gycxp66grqcnq3zdarfn4kvpym-fltk-1.3.3/include

@cstrahan
Copy link

cstrahan commented Feb 3, 2016

It looks like when fltkhs-fluidtohs is built, it's not adding -lfltk_gl as a flag to the linker.

@deech
Copy link
Owner

deech commented Feb 4, 2016

Thanks for the feedback. I added the fltk_gl to the extra-libraries stanza and got link errors.

Unfortunately I'm in the throes of prepping for my talk on Friday. Do you have a non-Nix environment you can use for the time being? Can we talk about it for a bit after the talk? My knowledge of Nix is approximately 0.

@sboosali
Copy link
Contributor

Can we add a build-tools: fltk-config? In the latest version, I see only build-tools: c2hs.

@peti also, to avoid GL dependencies if the flag isn't enabled, requires a custom (non cabal2nix) nix file, something like:

{
...
, opengl ? false
}:

mkDerivation {    
 ...
 configureFlags = if opengl then [ "-fopengl" ] else [];
 ...
}

correct? I don't know how deeply cabal2nix can support flags/conditionals.

@deech
Copy link
Owner

deech commented Jan 13, 2018

fltk-config is not added as a build tool because in the case of the bundled install (which I really want to support) it isn't available until after the preConf hook.

@sboosali
Copy link
Contributor

sboosali commented Jan 13, 2018 via email

@sboosali
Copy link
Contributor

e.g.

if flag(bundled) 
   build-tools: c2hs
else
   build-tools: c2hs, fltk-config
   extra-libraries: fltk

@deech
Copy link
Owner

deech commented Jan 13, 2018

I just updated the Nix branch to add fltk-config as a build tool as you suggest. However for the libraries it's an issue because which libraries get linked in are determined by fltk-config. For example on Linux, when configure is run fltk-config populates fltkhs.buildinfo with approximately:

ld-options: libfltk_images.a libfltk_png.a libfltk_z.a libfltk_jpeg.a libfltk_forms.a libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 -lstdc++

On Windows and OSX it links libraries specific to the platform. In the case that the opengl flag was passed it would also automatically add libfltk_gl -lGL -lglut.

I tried to include fltk-config into the Cabal file but I could never figure out how to use it during the build process to add to ld-options. Would be nice if Cabal (or some alternative) supported something like:

ld-options: $(fltk-config -- --use-gl --use-images --use-forms --ldflags)

@sboosali
Copy link
Contributor

thanks!

i'll try to port some of the build logic to nix. since nix doesn't support windows, and since i don't have a mac to test, (and honestly, since i'm new to nix myself), i'll just try to get something working on linux.

one existing nix-ified package seems to be using fltk-config:

https://github.com/NixOS/nixpkgs/blob/a982b20c3601e5376aa6508b8cadc809b05542b8/pkgs/applications/graphics/exrdisplay/default.nix#L18

@sboosali
Copy link
Contributor

also, do you know if fltk-1.3.4 works with fltkhs? (the bundled version seems to be fltk-1.3.4.1, and idk if they're the same). when you install fltk via nix on the unstable channel:

nix-env -i fltk

you get

installing ‘fltk-1.3.4’

by default. so for the non-bundled build, i'm gonna try to use that, since it works and is cached.

@deech
Copy link
Owner

deech commented Jan 13, 2018

Great! Appreciate the help.

If you can link me to the Nix source of fltk 1.3.4, I can diff it against 1.3.4-1 and confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants