extra-bundled-libraries problem: cannot find existing library
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
Guys, maybe it's a bug but maybe it's just a question.
I try to link with a dynamic library written in Go (I have not it's source and it's located in the project sub-directory as `clib/mylib/libmylib.so`). After a lot of investigation and experiments I found that there is an option `extra-bundled-libraries:` which could work, but it does not. It reports me an error that the cabal cannot find such library. I followed the naming convention but without any success: it reported a list of possible (but missing) names and one of them **actually existed on the disk**! After usage of `strace` I found that cabal tries to find it in the directory `$MY_PROJECT/dist-newstyle/build/x86_64-linux/ghc-9.2.3/project-0.1.0.0/build/` with a name `libmylib-ghc9.2.3.so` ! Why in this directory?
Well, I copied the `libmylib.so` to `$PROJECT_ROOT/dist-newstyle/build/x86_64-linux/ghc-9.2.3/project-0.1.0.0/build/libmylib-ghc9.2.3.so` and it started to fail differently: that the linked cannot find **mylib** : "-lmylib: No such file or directory" now.
So, I created a symbolic link in the same directory, so `libmylib.so -> libmylib-ghc9.2.3.so` and voila, now cabal is able to process the directive:
```
...
extra-bundled-libraries:
mylib
...
```
and I get valid executable.
My environment:
```
OS: Linux OpenSUSE
LSB: LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64"
Cabal: 3.8.1.0
GHC: 9.2.3
```
I have to refer mylib in a platform independent way and independently on particular file system paths (it will be in the repository and other users use different locations in their systems).
So, is it a bug?
- Or I have to copy mylib dynamic library to this directory really under 2 names (with versioned GHC suffix and without it)?
- Is there a more convenient way to do it?
- What to do in the case of Windows?
- If I will edit on the fly the cabal file (with Makefile or similar) than how to find the directory where the library should be located? Something with `cabal exec ghc-pkg` ? Or there is an another way?
Contributor guide
Research direction
No source file or test is named. Start by reproducing the extra-bundled-libraries behavior with Cabal 3.8.1.0 and GHC 9.2.3, tracing the lookup of clib/mylib/libmylib.so and the generated build directory. Done means the expected platform-independent library reference works without manually copying or linking files, with the Windows case clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100