On a mac, I've done brew install freetds
, which gives me a file libtdsodbc.so
. Now I try to link to that by putting the path to it in extra-lib-dirs
in my .cabal, but I get
* Missing (or bad) C library: tdsodbc
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
Doing stack build --verbose
shows me the command that fails was cabal configure, so I run that again with -v3
appended, which tells me:
/usr/bin/gcc -fno-stack-protector /var/folders/bq/4xy9knvx413dwltf9c6ngvvm0000gt/T/29185-4.c -o /var/folders/bq/4xy9knvx413dwltf9c6ngvvm
0000gt/T/29185-5 '-D__GLASGOW_HASKELL__=804' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -
I.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/autogen -I. -I/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/base-4
.11.1.0/include -I/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/integer-gmp-1.0.2.0/include -I/Users/unhammer/.stac
k/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/include -ltdsodbc -L/Users/unhammer/src/tds/lib -L/Users/unhammer/.stack/programs/x86_64-o
sx/ghc-8.4.3/lib/ghc-8.4.3/base-4.11.1.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/integer-gmp-1.0.2.0 -L/Use
rs/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/ghc-prim-0.5.2.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/l
ib/ghc-8.4.3/rts
/usr/bin/gcc returned ExitFailure 1 with error message:
ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file
'/Users/unhammer/src/tds/lib/libtdsodbc.so' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
/usr/bin/gcc -fno-stack-protector /var/folders/bq/4xy9knvx413dwltf9c6ngvvm0000gt/T/29185-6.c -o /var/folders/bq/4xy9knvx413dwltf9c6ngvvm
0000gt/T/29185-7 -ltdsodbc -L/Users/unhammer/src/tds/lib -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/base-4.11.1.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/integer-gmp-1.0.2.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/ghc-prim-0.5.2.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/rts
/usr/bin/gcc returned ExitFailure 254 with error message:
ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file
'/Users/unhammer/src/tds/lib/libtdsodbc.so' for architecture x86_64
clang: error: unable to execute command: Segmentation fault: 11
clang: error: linker command failed due to signal (use -v to see invocation)
/usr/bin/gcc -fno-stack-protector /var/folders/bq/4xy9knvx413dwltf9c6ngvvm0000gt/T/29185-8.c -o /var/folders/bq/4xy9knvx413dwltf9c6ngvvm
0000gt/T/29185-9 -ltdsodbc -L/Users/unhammer/src/tds/lib -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/base-4.11.
1.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/integer-gmp-1.0.2.0 -L/Users/unhammer/.stack/programs/x86_64-os
x/ghc-8.4.3/lib/ghc-8.4.3/ghc-prim-0.5.2.0 -L/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/rts
/usr/bin/gcc returned ExitFailure 1 with error message:
ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file
'/Users/unhammer/src/tds/lib/libtdsodbc.so' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
/usr/bin/gcc -fno-stack-protector /var/folders/bq/4xy9knvx413dwltf9c6ngvvm0000gt/T/29185-10.c -o /var/folders/bq/4xy9knvx413dwltf9c6ngvv
m0000gt/T/29185-11 -c '-D__GLASGOW_HASKELL__=804' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH
=1' -I.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/autogen -I. -I/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/b
ase-4.11.1.0/include -I/Users/unhammer/.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/integer-gmp-1.0.2.0/include -I/Users/unhammer/
.stack/programs/x86_64-osx/ghc-8.4.3/lib/ghc-8.4.3/include
Why can't ld
link to MH_BUNDLE? Can cabal only link to dylib
's on mac, or do I need some special options?
EDIT: Solved by instead linking to the dylib's that the .so links to.