Link against local shared library in a stack project

I am currently working on a gui project that uses qt5 for ui and haskell for logic. My project setup is like this

.
├── package.yaml
├── qt5-ui
│   ├── CMakeLists.txt
│   ├── build
│   │   ├── libqt5-ui.dylib
│   └── src
├── src
├── stack.yaml

I want to link the libqt5-ui.dylib to the main haskell project. I current know that there are two way to do this:

  • add this to package.yaml

extra-libraries: qt5-ui
extra-lib-dirs: qt5-ui/build/

  • add this to ghc-options

-L$(“pwd”)/qt5-ui/build
-lqt5-ui

The first one does not work because executable says relative library path makes no sense. And for the second one, ghc says directory does not exist.

My question is what is the correct way to setup this compile steps? And is it possible to let stack build cmake steps before run stack build?

Thank you!

1 Like

I just realized that you should set extra-lib-dirs as list in stack.yaml but not package.yaml. It seems that the problem is solved.