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

Find libraries via pkgconfig #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bennofs
Copy link

@bennofs bennofs commented Aug 26, 2015

Not all distributions have libraries in the standard paths. Using pkgconfig should be more reliable and avoids the need to hardcode paths to the library.

As an example, this patch makes hcwiid compile on NixOS.

Not all distributions have libraries in the standard paths. Using pkgconfig should be more reliable and avoids the need to hardcode paths to the library.
@bennofs
Copy link
Author

bennofs commented Oct 13, 2016

What is the status of this?

@ivanperez-keera
Copy link
Contributor

The status is that I could never see implications of using pkgconfig. It would probably work for me but would it still compile on hackage without problems and generate docs? How about on OSs other than Ubuntu? Will people need to edit the cabal file if they do not have pkg-config?

In this particular case, hcwiid only works on linux, and most users have pkg-config by default, but it requires glibc, which requires GTK on windows, so I'm not sure it's a good idea in the general case. I'm not complaining, just trying to understand what's best and find a solution that works in most cases if that's possible.)

@bennofs
Copy link
Author

bennofs commented Apr 1, 2017

Sorry, I'm not familar with all of the portability aspects of pkg-config. IME pkg-config solutions often work better than hardcoded paths. But as I don't really have much experience with this, I will close the PR for now.

@bennofs bennofs closed this Apr 1, 2017
@ivanperez-keera
Copy link
Contributor

ivanperez-keera commented Apr 2, 2017

There is not problem with having this open at all. Also, I may take over freenect, and other wrapper libraries, which means I'll have to make a decision about them at some point.

Instead of closing it, why don't we try to see how this could be addressed for other projects too, especially how large projects do it, and maybe come up with a better solution for all of them?

I can give more details, which may help understand my issues.

(EDIT: reworded second paragraph)

@ivanperez-keera
Copy link
Contributor

ivanperez-keera commented Apr 2, 2017

In particular: you say that one can still provide manual paths if pkg-config is not available. How? Does the standard --extra-include-dirs --extra-lib-dirs work? Won't cabal complain that it can't find the libraries' .pc files? Won't it complain if the executable pkg-config is not found?

I'm actually happy accepting this patch if we can enclose it in some conditional that makes it possible to use an alternative that works if there is not .pc file and the pkg-config executable is not in the system (unless it's required by GHC these days).

@bennofs
Copy link
Author

bennofs commented Apr 2, 2017

Ok, I will test this out. The reason I closed this PR was that I was going through my "list of open PRs" and closed everything that I no longer cared much about (because a PR that is staying around a long time with no activity might as well be closed). If you feel that this would be a good change though, I'm happy to help! I'll see if I can find out how cabal behaves if pkg-config is not available.

@bennofs
Copy link
Author

bennofs commented Apr 2, 2017

It looks like cabal really does have a hard requirement on pkgconfig if you use pkg-config depends:

hcwiid (bennofs-patch-1 ⚡=) $ cabal configure
Warning: The package list for 'hackage.haskell.org' is 58 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring hcwiid-0.0.6...
cabal: The program 'pkg-config' version >=0.9.0 is required but it could not
be found.

I can't find any way to avoid this. We can add a flag no-pkgconfig to allow building without pkg-config as well (by making the pkg-config depend conditional based on the flag), but discoverabilty of that flag would be bad as cabal won't mention it in its error message.

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

Successfully merging this pull request may close these issues.

2 participants