【发布时间】:2014-04-19 20:50:45
【问题描述】:
我正在尝试通过一些第三方模块制作一个依赖于icu 库的程序。我怀疑依赖是通过Network.HTTP.Conduit,但可能是通过其他方式。动态链接的二进制文件即使在同一发行版的相邻版本之间也不能移植,因为 libicu* 的不同版本不兼容。
所以我正在尝试静态构建程序:
$ ghc --make -static -optc-static -optl-static my-prog.hs -optl-pthread
我遇到了很多此类错误:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libicuuc.a(dictionarydata.ao):(.data.rel.ro._ZTIN6icu_5222BytesDictionaryMatcherE[_ZTIN6icu_5222BytesDictionaryMatcherE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libicuuc.a(dictionarydata.ao):(.data.rel.ro._ZTVN6icu_5217DictionaryMatcherE[_ZTVN6icu_5217DictionaryMatcherE]+0x28): undefined reference to `__cxa_pure_virtual'
collect2: error: ld returned 1 exit status
我相信我拥有所有相关库的静态版本(libicu、libstdc++)。似乎链接器没有提供libstdc++(或者是libitl?显然有问题的函数是在后者中定义的)。
我尝试将选项-optl-static-libstdc++、-optl-lstdc++ 和-optl-litm 添加到命令行末尾,但无济于事。
静态链接间接依赖于 C++ 支持函数的 haskell 程序的过程是什么?我在跑步
The Glorious Glasgow Haskell Compilation System, version 7.6.3
gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
或
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
编辑:
我将问题缩小到包Data.Text.ICU,这里有一个不能内置到静态可执行文件中的短程序:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Text.ICU
main = print $ toUpper Current "Hello!"
【问题讨论】: