未定义的符号引用 'pthread_setname_np@@GLIBC_2.12' Haskell OpenSuse42.3 上的堆栈错误
undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12' Haskell Stack error on OpenSuse42.3
我已经安装了 haskell 堆栈,我正在尝试为此设置 ghc。堆栈版本是
stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1
我已经更新了 ~/.stack/global-project/stack.yaml 如下
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project. Settings here do _not_ act as
# defaults for all projects. To change stack's default settings, edit
# '/home/rajkumar/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/
#
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: ghc-8.2.1
然后我 运行 堆栈设置命令并得到以下错误 -
stack setup
The GHC located at /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc /tmp/stack-sanity-check3048/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check3048/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check3048/Main.hs, /tmp/stack-sanity-check3048/Main.o )
Linking /tmp/stack-sanity-check3048/Main ...
/usr/bin/ld.bfd: /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/lib64/ghc-8.2.1/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
So maybe the problem is that you need GLIBC_2.12 installed on your machine and not 2.26
不,那是不是的问题。 GLIBC-2.26 肯定会提供 pthread_setname_np@@GLIBC_2.12
符号(请参阅 了解符号版本控制的工作原理)。
您可以像这样验证该符号在您的 GLIBC-2.26 中确实可用:
$ readelf -Ws /lib/x86_64-linux-gnu/libpthread.so.0 | grep pthread_setname_np
89: 00000000000113c0 258 FUNC GLOBAL DEFAULT 13 pthread_setname_np@@GLIBC_2.12
704: 00000000000113c0 258 FUNC GLOBAL DEFAULT 13 pthread_setname_np
(以上命令是在 GLIBC-2.19 系统上执行的,但在 GLIBC-2.26 系统上你会得到相同的输出)。
现在你的真实问题是:libHSrts.a(OSThreads.o)
references pthread_setname_np
(可能还有其他pthread_*
符号,但您没有使用 -pthread
或 -lpthread
标志链接。
我不知道在哪里将这个标志添加到 GHC,但是一旦你找到了,你的问题就解决了。
我已经安装了 haskell 堆栈,我正在尝试为此设置 ghc。堆栈版本是
stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1
我已经更新了 ~/.stack/global-project/stack.yaml 如下
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project. Settings here do _not_ act as
# defaults for all projects. To change stack's default settings, edit
# '/home/rajkumar/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/
#
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: ghc-8.2.1
然后我 运行 堆栈设置命令并得到以下错误 -
stack setup
The GHC located at /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc /tmp/stack-sanity-check3048/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check3048/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check3048/Main.hs, /tmp/stack-sanity-check3048/Main.o )
Linking /tmp/stack-sanity-check3048/Main ...
/usr/bin/ld.bfd: /home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/lib64/ghc-8.2.1/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
So maybe the problem is that you need GLIBC_2.12 installed on your machine and not 2.26
不,那是不是的问题。 GLIBC-2.26 肯定会提供 pthread_setname_np@@GLIBC_2.12
符号(请参阅
您可以像这样验证该符号在您的 GLIBC-2.26 中确实可用:
$ readelf -Ws /lib/x86_64-linux-gnu/libpthread.so.0 | grep pthread_setname_np
89: 00000000000113c0 258 FUNC GLOBAL DEFAULT 13 pthread_setname_np@@GLIBC_2.12
704: 00000000000113c0 258 FUNC GLOBAL DEFAULT 13 pthread_setname_np
(以上命令是在 GLIBC-2.19 系统上执行的,但在 GLIBC-2.26 系统上你会得到相同的输出)。
现在你的真实问题是:libHSrts.a(OSThreads.o)
references pthread_setname_np
(可能还有其他pthread_*
符号,但您没有使用 -pthread
或 -lpthread
标志链接。
我不知道在哪里将这个标志添加到 GHC,但是一旦你找到了,你的问题就解决了。