How to generate library with a specific name via cabal

Viewed 52

I am trying to build a shared Haskell library that is used by a C project afterwards. I am on a linux platform so my question is from that context.

Suppose I have a haskell package foo with a library named foo, say version 0.1 which exports some functions via ffi.

I can easily generate a shared library (.so) that I can then link with, but my issue is that the generated library is named libHSfoo-0.1-$COMPONENT_ID.so which makes it quite cumbersome to link with since $COMPONENT_ID is unpredictable as far as I can tell.

The $COMPONENT_ID comes, to the best of my knowledge from the following Cabal structure and it looks like I could write cabal hooks to at least copy the generated shared library, or create a symbolic link to it from a fixed location.

I am wondering whether there is a better way to specify the component-id to get an easily predictable name of the shared library without post-processing?

It seems like I can achieve this if in the configure hook I set the configArgs to just the library component, and the configCID to my desired name of the library, but that seems like a fragile solution and I am thinking there is a better way for this.

The name of the library also affects linking when there are other Haskell packages dependent on this one, which would make it even more convenient to specify/override the name.

I am using stack to drive cabal, if that is relevant.

0 Answers
Related