-
Notifications
You must be signed in to change notification settings - Fork 711
extra-lib-dirs
does not propagate to dependencies when building
#9222
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
Comments
Also, appreciate any suggestions to linking the library more reliably. |
This is by design for now. See: https://cabal.readthedocs.io/en/stable/cabal-project.html#package-configuration-options There's discussion at #2997 on various alternatives that might be possible, but its all a bit tricky. |
(note that the ticket provides a recommended way to specify extra-lib-dirs for dependencies, specifically through use of a |
tl;dr:
either in cabal.project if you are already using one, or in cabal.project.local. (The only difference being that if cabal.project is missing EDIT: actually, as @gbaz mentions in the linked thread, the best practice is to put that snippet in cabal.project.local, since that path is system dependent and cabal.project.local is typically ignored doing source version control). |
Thanks, @gbaz @andreabedini. I'll have a look on the references. |
@andreabedini Ah, the |
I'm against closing this issue, because #2997 addresses only some use cases. For me, an important use case is when I'm installing a package from (e.g.) Hackage, that package pulls a pile of dependencies, and all of them must link to a library that's not on the standard system search path.
I mentioned all this in #2997. |
@mouse07410 I wrote a summary in #2997, I hope I have captured your use case.
I am not sure what problem you are running into, what do you mean by "top-package"? (I did try by compiling Z-Botan but it worked without any extra library 🤷). I listed the workarounds I know of in my summary. I suggest we leave this closed and move any discussion to the other ticket. |
I see "homebrew" in there so I presume they're on a Mac. Homebrew installs most things in |
@geekosaur I had previous installations of homebrew that create But good point. I'll check if installing packages from |
Another option I tried was |
Your post in the other ticket summed it up: my use case will not be supported. Specifically, if a library, like OpenSSL libs, that is not in a standard location like /usr/lib or /usr/local/lib that I want the package from Hackage and all of its dependencies to use, they're no way to do that. |
Did I say it will not be supported? If I did it was not what I had meant to say. My intention was to describe the current status quo, issues and workarounds.
I listed two options: 1) adding extra-lib-dirs to the global cabal config 2) setting the LIBRARY_PATH environment variable. I am afraid that's all the help I can offer. |
This is pretty much what I'm doing now. And it's fine for libraries that are truly system-wide (though in non-standard locations). However, in (admittedly rate) cases when some groups of packages need to use a "standard" (usually, OS-provided) library, while other groups require the "non-standard" (e.g., Macports- or Brew-installed), there's a problem.
No, this doesn't work. LIBRARY_PATH tells the loader where to find the already-linked dynamic/shared libraries the executable needs to load. It does not tell the linker where to look for the libraries (static or dynamic) to build/link the executable.
That's what I meant in my previous post. One partial solution (admittedly, good enough for majority of my use cases, and already employed), and one no-solution. |
Unless I got the names mixed up, I think gcc uses LIBRARY_PATH to inform the linker while the loader uses LD_LIBRARY_PATH. This, of course, assumes gcc is doing the linking. |
GCC to the best of my knowledge invokes system linker (from XCode) on MacOS, but I'm not sure. In any case, thanks for the useful information - let me test it. I assume |
It's described in gcc documentation Let us know if it works! |
Describe the bug
extra-lib-dirs
does not propagate to dependencies when building.Dependency A uses a library that is installed on a non-standard path (in this case is brew on macOS).
Project B used A and tries to compile with
To Reproduce
Steps to reproduce the behavior:
extra-libraries: {library}
--extra-lib-dirs
so the compiler can find the libraryExpected behavior
extra-libraries
should be found at--extra-lib-dirs
paths.System information
cabal 3.10.1.0
,ghc 9.2.8
(nix)Additional context
cabal and ghc might be outdated. I'll see if it also happens on latest versions.
Logs:
The text was updated successfully, but these errors were encountered: