
Hello, I try to build a project which use C libraries. during the developpement I want to link directly with the work in progress libraries. So I added this in cabal. executable binoculars-ng [...] if flag(useHklDev) pkgconfig-depends: gobject-2.0 ghc-options: -pgml ghc-options: gcc ghc-options: "-optl-Wl,--allow-multiple-definition" ghc-options: "-optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive" ghc-options: "-optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive" at the end I have a working executable. Building executable 'binoculars-ng' for hkl-0.1.0.0.. [1 of 1] Compiling Main ( app/Binoculars.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp/Main.o ) Linking /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng ... But now I would like to create an unit test so I added this in cabal test-suite hkl-test [...] if flag(useHklDev) pkgconfig-depends: gobject-2.0 ghc-options: -pgml ghc-options: gcc ghc-options: "-optl-Wl,--allow-multiple-definition" ghc-options: "-optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive" ghc-options: "-optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive" but this time during the compilation I end up with this error message [1 of 3] Compiling Paths_hkl ( /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/autogen/Paths_hkl.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/hkl-test-tmp/Paths_hkl.o ) [2 of 3] Compiling BinocularsSpec ( test/BinocularsSpec.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/hkl-test-tmp/BinocularsSpec.o ) <command line>: /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/build/libHShkl-0.1.0.0-inplace-ghc8.8.4.so: undefined symbol: hkl_binoculars_cube_free both the executable and the test use this hkl_binoculars_cube_free function. So are you aware of a difference between test suit and executable during the build. more precisely are both executables compiled differently ? thanks for you help Frederic

That error message looks like it's coming from TH instead of final
link, so you may need to do something else to make it available to TH
during compile.
On Mon, Jan 10, 2022 at 3:50 AM PICCA Frederic-Emmanuel
Hello, I try to build a project which use C libraries.
during the developpement I want to link directly with the work in progress libraries. So I added this in cabal.
executable binoculars-ng [...]
if flag(useHklDev) pkgconfig-depends: gobject-2.0 ghc-options: -pgml ghc-options: gcc ghc-options: "-optl-Wl,--allow-multiple-definition" ghc-options: "-optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive" ghc-options: "-optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive"
at the end I have a working executable.
Building executable 'binoculars-ng' for hkl-0.1.0.0.. [1 of 1] Compiling Main ( app/Binoculars.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp/Main.o ) Linking /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng ...
But now I would like to create an unit test so I added this in cabal
test-suite hkl-test [...] if flag(useHklDev) pkgconfig-depends: gobject-2.0 ghc-options: -pgml ghc-options: gcc ghc-options: "-optl-Wl,--allow-multiple-definition" ghc-options: "-optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive" ghc-options: "-optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive"
but this time during the compilation I end up with this error message
[1 of 3] Compiling Paths_hkl ( /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/autogen/Paths_hkl.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/hkl-test-tmp/Paths_hkl.o ) [2 of 3] Compiling BinocularsSpec ( test/BinocularsSpec.hs, /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/t/hkl-test/build/hkl-test/hkl-test-tmp/BinocularsSpec.o ) <command line>: /home/experiences/instrumentation/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/build/libHShkl-0.1.0.0-inplace-ghc8.8.4.so: undefined symbol: hkl_binoculars_cube_free
both the executable and the test use this hkl_binoculars_cube_free function.
So are you aware of a difference between test suit and executable during the build.
more precisely are both executables compiled differently ?
thanks for you help
Frederic
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh allbery.b@gmail.com

----- Brandon Allbery
That error message looks like it's coming from TH instead of final link, so you may need to do something else to make it available to TH during compile.
I used the -v option in order to have detailed error message executable --------------- creating /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp /usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i. -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id containers-0.6.2.1 -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id exceptions-0.10.4-9CfD2hJyZLFIbks3iYGf0k -package-id filepath-1.4.2.1 -package-id hkl-0.1.0.0-inplace -package-id monad-logger-0.3.34-CJMMf2yR5GpALmIIglLyst -package-id monad-loops-0.4.3-9fN6QF5xEO8BUJUobxjHs -package-id optparse-applicative-0.15.1.0-GiY4uo4FBQRKuBqOktTXko -package-id pipes-4.3.14-KiHrcdQOQdo1w0hHviOVEE -package-id text-1.2.4.0 -package-id transformers-0.5.6.2 -package-id vector-0.12.1.2-C2W44iPdAFeHo4yLU081Gd -XHaskell2010 ./app/Binoculars.hs -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages test ----- /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp /usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -itest -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id config-ini-0.2.4.0-D7dieWR57bgihPQO3mLYW -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id hkl-0.1.0.0-inplace -package-id hspec-2.7.1-5JvuKFX0Z3iFazfgnEEvF6 -package-id path-0.7.0-ItQkMO2BJUADmjR5L3rHpY -package-id text-1.2.4.0 -XHaskell2010 BinocularsSpec Paths_hkl test/Spec.hs -threaded '-rtsopts=all' '-with-rtsopts=-K1k' -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages [1 of 1] Compiling Main ( app/Binoculars.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp/Main.o ) [1 of 3] Compiling Paths_hkl ( /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen/Paths_hkl.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp/Paths_hkl.o ) [2 of 3] Compiling BinocularsSpec ( test/BinocularsSpec.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp/BinocularsSpec.o ) <command line>: /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/build/libHShkl-0.1.0.0-inplace-ghc8.8.4.so: undefined symbol: hkl_binoculars_cube_free Linking... /usr/bin/ghc --make -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i. -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen/cabal_macros.h -lgobject-2.0 -lglib-2.0 -L/home/picca/src/repo.or.cz/hkl/binoculars/ -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id containers-0.6.2.1 -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id exceptions-0.10.4-9CfD2hJyZLFIbks3iYGf0k -package-id filepath-1.4.2.1 -package-id hkl-0.1.0.0-inplace -package-id monad-logger-0.3.34-CJMMf2yR5GpALmIIglLyst -package-id monad-loops-0.4.3-9fN6QF5xEO8BUJUobxjHs -package-id optparse-applicative-0.15.1.0-GiY4uo4FBQRKuBqOktTXko -package-id pipes-4.3.14-KiHrcdQOQdo1w0hHviOVEE -package-id text-1.2.4.0 -package-id transformers-0.5.6.2 -package-id vector-0.12.1.2-C2W44iPdAFeHo4yLU081Gd -XHaskell2010 ./app/Binoculars.hs -o /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages Linking /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng ... CallStack (from HasCallStack): die', called at ./Distribution/Client/ProjectOrchestration.hs:1035:55 in main:Distribution.Client.ProjectOrchestration cabal: Failed to build hkl-0.1.0.0-inplace-hkl-test. the difference is that there is no link phase for the executable binary (it has only one file). I see no reference to TH during the compilation of this part of the code. (It is true thaht I use TH in the librarie). Cheers Fred

In that case you were missing part of the error message, since it came
up at 2 out of 3 compiled and referenced "command line" instead of an
object file, and comes before the "Linking" message.
Given the forced link stuff I wonder if you need -Wl,-u
-Wl,hkl_binoculars_cube_free (or some variant thereof).
On Mon, Jan 10, 2022 at 5:51 AM PICCA Frederic-Emmanuel
----- Brandon Allbery
a écrit : That error message looks like it's coming from TH instead of final link, so you may need to do something else to make it available to TH during compile.
I used the -v option in order to have detailed error message
executable ---------------
creating /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp /usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i. -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id containers-0.6.2.1 -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id exceptions-0.10.4-9CfD2hJyZLFIbks3iYGf0k -package-id filepath-1.4.2.1 -package-id hkl-0.1.0.0-inplace -package-id monad-logger-0.3.34-CJMMf2yR5GpALmIIglLyst -package-id monad-loops-0.4.3-9fN6QF5xEO8BUJUobxjHs -package-id optparse-applicative-0.15.1.0-GiY4uo4FBQRKuBqOktTXko -package-id pipes-4.3.14-KiHrcdQOQdo1w0hHviOVEE -package-id text-1.2.4.0 -package-id transformers-0.5.6.2 -package-id vector-0.12.1.2-C2W44iPdAFeHo4yLU081Gd -XHaskell2010 ./app/Binoculars.hs -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages
test ----- /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp /usr/bin/ghc --make -no-link -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -itest -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen/cabal_macros.h -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id config-ini-0.2.4.0-D7dieWR57bgihPQO3mLYW -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id hkl-0.1.0.0-inplace -package-id hspec-2.7.1-5JvuKFX0Z3iFazfgnEEvF6 -package-id path-0.7.0-ItQkMO2BJUADmjR5L3rHpY -package-id text-1.2.4.0 -XHaskell2010 BinocularsSpec Paths_hkl test/Spec.hs -threaded '-rtsopts=all' '-with-rtsopts=-K1k' -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages [1 of 1] Compiling Main ( app/Binoculars.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp/Main.o ) [1 of 3] Compiling Paths_hkl ( /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/autogen/Paths_hkl.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp/Paths_hkl.o ) [2 of 3] Compiling BinocularsSpec ( test/BinocularsSpec.hs, /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/hkl-test/build/hkl-test/hkl-test-tmp/BinocularsSpec.o ) <command line>: /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/build/libHShkl-0.1.0.0-inplace-ghc8.8.4.so: undefined symbol: hkl_binoculars_cube_free Linking... /usr/bin/ghc --make -fbuilding-cabal-package -O -static -outputdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -odir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -hidir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -stubdir /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -i. -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -i/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/global-autogen -I/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng-tmp -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -optP-include -optP/home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/autogen/cabal_macros.h -lgobject-2.0 -lglib-2.0 -L/home/picca/src/repo.or.cz/hkl/binoculars/ -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/picca/.cabal/store/ghc-8.8.4/package.db -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/packagedb/ghc-8.8.4 -package-db /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/package.conf.inplace -package-id attoparsec-0.13.2.4-Ab3vFYnVhC6LY7sYuAbpTr -package-id base-4.13.0.0 -package-id containers-0.6.2.1 -package-id dimensional-1.3-C8v0k83E9Py18UKTdF1oLh -package-id exceptions-0.10.4-9CfD2hJyZLFIbks3iYGf0k -package-id filepath-1.4.2.1 -package-id hkl-0.1.0.0-inplace -package-id monad-logger-0.3.34-CJMMf2yR5GpALmIIglLyst -package-id monad-loops-0.4.3-9fN6QF5xEO8BUJUobxjHs -package-id optparse-applicative-0.15.1.0-GiY4uo4FBQRKuBqOktTXko -package-id pipes-4.3.14-KiHrcdQOQdo1w0hHviOVEE -package-id text-1.2.4.0 -package-id transformers-0.5.6.2 -package-id vector-0.12.1.2-C2W44iPdAFeHo4yLU081Gd -XHaskell2010 ./app/Binoculars.hs -o /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng -O2 -Wall -Werror -rtsopts -threaded -g -dcore-lint -debug -ddump-to-file -ddump-simpl -ddump-stg '-with-rtsopts=-N' -pgml gcc -optl-Wl,--allow-multiple-definition -optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive -optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive -hide-all-packages Linking /home/picca/src/repo.or.cz/hkl/contrib/haskell/dist-newstyle/build/x86_64-linux/ghc-8.8.4/hkl-0.1.0.0/x/binoculars-ng/build/binoculars-ng/binoculars-ng ... CallStack (from HasCallStack): die', called at ./Distribution/Client/ProjectOrchestration.hs:1035:55 in main:Distribution.Client.ProjectOrchestration cabal: Failed to build hkl-0.1.0.0-inplace-hkl-test.
the difference is that there is no link phase for the executable binary (it has only one file).
I see no reference to TH during the compilation of this part of the code. (It is true thaht I use TH in the librarie).
Cheers
Fred
-- brandon s allbery kf8nh allbery.b@gmail.com

Ok, just by adding if flag(useHklDev) extra-libraries: hkl-binoculars extra-libraries: hkl in the library part and if flag(useHklDev) ghc-options: "-optl-Wl,--allow-multiple-definition" ghc-options: "-optl-Wl,--whole-archive,../../hkl/.libs/libhkl.a,--no-whole-archive" ghc-options: "-optl-Wl,--whole-archive,../../binoculars/libhkl-binoculars.a,--no-whole-archive" in the test part, I solved this issue. thanks for your help Fred

Hello, In fact I changed my strategie and now I use cabal configure in order to gives the extra-lib-dirs and extra-include-dirs It works great for the build but When I try to run the program it end up with a can not found library libhkl.so.5 So my question is why theses extra-lib-dirs are not added to the LD_LIBRARY_PATH when we use cabal run <programm> and cabal test Cheers Frederic

So it works fine with `cabal run` and `cabal test` when the extra dirs are
in .cabal file, but not fine when they are in the cabal.project.local file?
There may or may not be a good reason for that. Could you
search the cabal's issue tracker and either add to a ticket
or create a new one? Thank you!
On Mon, Jan 10, 2022 at 5:53 PM PICCA Frederic-Emmanuel
Hello, In fact I changed my strategie and now I use
cabal configure in order to gives the extra-lib-dirs and extra-include-dirs
It works great for the build
but When I try to run the program it end up with a can not found library libhkl.so.5
So my question is why theses extra-lib-dirs are not added to the LD_LIBRARY_PATH when we use
cabal run <programm>
and
cabal test
Cheers
Frederic _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

So it works fine with `cabal run` and `cabal test` when the extra dirs are in .cabal file, but not fine when they are in the cabal.project.local file? There may or may not be a good reason for that. Could you search the cabal's issue tracker and either add to a ticket or create a new one? Thank you!
No in fact the first success story was a mistake.. due to a local install of the library which was in the default search path of gcc. So now I need to wrap cabal test and cabal run binoculars-ng in order to set LD_LIBRARY_PATH=<path to the extra library> It seesm strage to me that this is required when we gives cabal configure extra-lib-dirs. cheers Fred
participants (3)
-
Brandon Allbery
-
Mikolaj Konarski
-
PICCA Frederic-Emmanuel