-
Notifications
You must be signed in to change notification settings - Fork 848
Linking error when dependency uses own 'extra-library' #4141
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
I can reproduce (with a different resolver, on ghc 8.2.2). I am, though, able to build I'll find somebody who knows more — it should work automatically. |
It also doesn't work with a custom snapshot. |
Thank you very much for your response. The command
For a reason I'm not aware of, it asks for a shared library instead of the static one i would expect it to. Thank's again. |
Have you tried playing with ghc-options:
- -optl-Wl,-rpath,$ORIGIN/.stack-work It would be helpful to have the same example project to work with, so would you please make a repo on github that we can use as a minimum example? |
Hi. I'm sorry for answering so late. I was able to make it work, but the solution was sub-optimal. Basically, what I did was to change the information of the Of course, that's not a very good solution:
I don't know how to solve in a better way. On the whole, I think a tutorial on the different elements of a I'm willing to contribute in helping in any way I can to make it easier for other people that encounter the same trouble (C binding packages will probably be the ones encounter it the most). |
For a working example of using HasCacBDD in another stack project, see https://github.com/jrclogic/SMCDEL/. (I am the author of HasCacBDD and SMCDEL 😉) Still, a bug in stack might be that -- location:
- git: https://github.com/m4lvin/HasCacBDD.git
- commit: 23405da09876356569fbbb4f150e33199e5546f9
- extra-dep: true
+
+extra-deps:
+- HasCacBDD-0.1.0.0 ... it no longer builds but fails with:
(Note that the git commit and the version 0.1.0.0 on hackage have identical code besides the README.) Maybe someone can explain the difference between the two PS: Some information how the |
- see commercialhaskell/stack#4141 for discussion - clean up `package.yaml` - `.gitignore`s `SMV-Haskell.cabal`
Just to add to what Malvin has commented, the error happens even when using the -extra-deps:
- - HasCacBDD-0.1.0.0
+
+extra-deps:
+ - git: https://github.com/m4lvin/HasCacBDD.git
+ commit: 23405da09876356569fbbb4f150e33199e5546f9 Make the package work correctly. So probably the question to ask is "Why is it working correctly with a |
Could it be a problem with the package itself? |
Possibly, we should check with Malvin.
…On Thu, Sep 20, 2018 at 1:34 AM dbaynard ***@***.***> wrote:
Could it be a problem with the package itself?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4141 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQLbpg48VQuALqvwaKtBlEaSvbtbR9Ztks5uczb4gaJpZM4VIaLu>
.
|
I tried to make a more minimal example , but still using HasCacBDD, see here: Note that: 1, There is different behavior even between only giving the package name and version to get it from Hackage vs. giving the full URL to the same Hackage package?! From https://docs.haskellstack.org/en/stable/yaml_configuration/#packages-and-extra-deps I understood that all methods to get an extra-deps package should do the same, but apparently they don't. Maybe you can point us to the relevant stack source code to see what happens? To test whether this also happens with other packages we need another package that (i) builds a shared library via Setup.hs (ii) is available on Hackage and (iii) is also available in a git repository. I don't know of any immediately. For Edit: Maybe https://github.com/jakubfijalkowski/hlibsass would be another example? |
Are there any news about this or hints how to debug it further? Can someone point us to the relevant source code of stack? To summarize the question: Why does stack treat |
With hackage, all the information is present in the hackage tarball. With repository extra-deps, stack has to download the repo and then process it. This is changing, though. No news. That said, there have been new releases since then, and it may also be worth trying on the master branch as that completely changes the way git dependencies work. |
Thank you for the hint! I just tried to build SMCDEL with stack from the master branch and now it fails with Hence I will not be able to build my projects with stack 2 when it comes out 😿 I also want to clarify that I am by no means sure the problem is not with my package. If someone can look at https://github.com/m4lvin/HasCacBDD/blob/master/HasCacBDD.cabal etc. and has a better idea how to make a package including Haskell-to-C-to-C++ FFI more stack friendly, I would be very happy! |
🤦 that's not good! Does HasCacBDD still build directly, just not as a dependency? I wonder whether it has anything to do with the custom setup? Specifically, the following line jumped out at me: https://github.com/m4lvin/HasCacBDD/blob/b5a9ab0ffc0e9cb41f18523036e476208f0a580a/Setup.hs#L51 Building as a snapshot dependency would (I believe) place the library into the |
It does still build directly. I can run If I build SMCDEL depending on HasCacBDD with the current stack master, this debugging line prints
That latter folder does then indeed contain An easier example than HasCacBDD might be https://github.com/jakubfijalkowski/haskell-and-cpp from where I copied the method of the flying Note that I am running stack master and stack 1.9.3 with the same |
Given that stack 2 was now released, this became a bit more urgent for me. Could someone look at https://github.com/m4lvin/depender or give me other ideas how to debug the problem? |
Thank you! I am unsure about the relation to #4855. Indeed,
(whereas with old stack 1.9.3 this works) |
I did some more experiments. It seems stack 2 also ignores any In general, I think I only now learned that Sorry for all the confusion 😕 (I also stumbled into haskell/cabal#1317 but I think the problem here is whether the update: some good news: https://github.com/jakubfijalkowski/hsass does build with stack 2, even though it depends on https://github.com/jakubfijalkowski/hlibsass which also uses a custom Setup.hs to make a C and C++ library. Maybe @jakubfijalkowski can help? next update: In total, this might mean there is no bug in stack after all 😉 [*] with one exception that makes these problems hard to debug: |
Indeed this solves the problem. HasCacBDD 0.1.0.2 can now be used in |
I was on vacations and couldn't respond, sorry. I'm glad that it was fixed (I am amazed that my 5-years-old post is still usable). :) |
It causes this issue when building on alpine: commercialhaskell/stack#4141
General summary/comments (optional)
I get a linking error by GNU gold when trying to add an external library:
/usr/bin/x86_64-linux-gnu-ld.gold: error: cannot find -lCacBDD collect2: error: ld returned 1 exit status
I tried it in my regular Ubuntu 18.04 machine and when that failed i used a clean virtual machine installation of the same distribution, I get the same error on both.
Steps to reproduce
With stack installed, I created a new project with a template:
Then import the module I want in
src/Lib.hs
(which is HasCacBDD):Then I include the dependency in the
package.yaml
file:And since the package is not included by default in any release of stack, I add the extra dependency in
the
stack.yaml
file:When I try to build the project, it simply does not work.
Expected
From a beginners point of view, this configuration looks very similar to the
acme-missiles
examplein the docs, nevertheless, that example works perfectly and this one does not.
I would expect it to build ok or at least show me some infomative message that would help me solve the problem.
Actual
A linker error.
As I mentioned before, the
acme-missiles
example works fine, and also, I am also able to build the package i'm trying to add directly (as explained in the docs).Stack version
I tried with both the latests LTS:
and also with the latest nightly
--resolver nightly-2018-07-09
getting the same error on both.Method of installation
Additional (maybe useful)
HasCacBDD is a binding to a C package using the FFI. Looking
at the error, it looks like the missing file is a library from that C package. Still, the error seems odd because if you execute the conventional
stack unpack HasCacBDD-0.1.0.0
and build it, all the code works just fine. Maybe the issue could be further specified by the question:Note: Looking at the code, the
Setup.hs
of the original package seems to be building and copying the mentionedlibCacBDD.a
static library into the correct folder inside the.stack-work
folder (it does so by running someMakefile
's on the original C code and then moving the built library into the folder).When the package is included as an
extra-dep
, thislibCacBDD.a
library is indeed being stored at.stack-work/install/x86_64-linux/resolver_version/ghc_version/lib/x86_64-linux-ghc_version/included_package_name/library.a
of my project, so probably the only thing that I need to do is to add this folder to library dependencies. It seems awkard and error prone to write the path I mentioned above, since it dependes on the particular resolver, operating system, and other settings of my project. Is there a more robust way to add this folder to my dependencies, maybe in an automatic way?Thanks in advance!
The text was updated successfully, but these errors were encountered: