macos - Haskell / cabal:可以链接到macos上的.so文件吗?
问题描述
在 Mac 上,我已经完成了brew install freetds
,这给了我一个文件libtdsodbc.so
。现在我尝试通过将路径放在我的.cabal中来链接到它extra-lib-dirs
,但我得到了
* 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.
这样做stack build --verbose
向我展示了失败的命令是 cabal configure,所以我再次运行它并-v3
附加,它告诉我:
/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
为什么不能ld
链接到 MH_BUNDLE?cabal 只能链接到dylib
mac 上的 's,还是我需要一些特殊选项?
编辑:通过链接到.so链接到的dylib来解决。
解决方案
推荐阅读
- unity3d - 将两个动画组合在一起
- python-2.7 - 将 .mdb 文件导入 Python
- docker - docker误恢复出厂设置
- javascript - 如果用户从组件的 url 导航到相同的 URL 但查询不同,如何强制路由重新呈现其组件
- javascript - 如何在悬停中显示标题 - css / jquery
- r - |>(管道大于)在R中是什么意思?
- report - 我们如何打印多个报告,例如我想在一个日期范围内为所有员工打印出勤报告?
- css - 用`!important`覆盖父类CSS不起作用?
- oracle - 为什么视图 V$_SEQUENCES 在 Oracle 12.1 中为空,但在 11.2、12.2、18.3、19.3 中工作?
- azure-pipelines - 无法在 ms-azure-devops 中创建管道