未定义的引用符号'pthread_setname_np @@ GLIBC_2.12'在OpenSuse42.3上的Haskell堆栈错误 [英] undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12' Haskell Stack error on OpenSuse42.3

查看:462
本文介绍了未定义的引用符号'pthread_setname_np @@ GLIBC_2.12'在OpenSuse42.3上的Haskell堆栈错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了haskell stack,并且正在尝试为ghc设置相同的功能。堆栈版本是

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $版本1.5.1版本Git修订版本600c1f01435a10d127938709556c1682ecfd694e(4861提交)x86_64 hpack- 0.17.1

我更新了〜/ .stack / global-project / stack.yaml,如下所示

 #这是隐含的全局项目的配置文件,仅当
#'stack'在外部运行时才会使用一个真正的项目。这里的设置不适用于所有项目的
#默认值。要更改堆栈的默认设置,请改为编辑
#'/home/rajkumar/.stack/config.yaml'。

#有关堆栈配置的更多信息,请参阅
#http://docs.haskellstack.org/en/stable/yaml_configuration/

flags: {}
extra-package-dbs:[]
packages:[]
extra-deps:[]
resolver:ghc-8.2.1

然后我运行堆栈设置命令并得到下面的错误 -

 堆栈设置
位于/home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc的GHC未能编译完整性检查。请参阅:

http://docs.haskellstack.org/en/stable/install_and_upgrade/

了解更多信息。例外情况是:
正在运行/home/rajkumar/.stack/programs/x86_64-linux/ghc-8.2.1/bin/ghc /tmp/stack-sanity-check3048/Main.hs -no-user-package- db在目录/ tmp / stack-sanity-check3048 /退出exitFailure 1

[1的1]编译Main(/tmp/stack-sanity-check3048/Main.hs,/ tmp / stack- sanity-check3048 / Main.o)
链接/ 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):对符号'pthread_setname_np @@ GLIBC_2.12'的未定义引用
/ lib64 /libpthread.so.0:添加符号时出错:命令行中缺少DSO
collect2:错误:ld返回1退出状态
`gcc'阶段'连接器'失败。 (退出码:1)


解决方案


<所以也许问题是你需要在你的机器上安装GLIBC_2.12而不是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的系统上获得相同的输出)。



现在,您的 real 问题是: libHSrts.a(OSThreads.o) c 引用 pthread_setname_np (可能还有其他 pthread _ * 符号,但是您没有链接到 -pthread 或 -lpthread 标志。



我不知道在哪里添加此标志GHC,但一旦你发现,你的问题将得到解决。


I have installed haskell stack and I'm trying to setup ghc for the same. stack version is

stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1

I have updated the ~/.stack/global-project/stack.yaml as below

# 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

Then I run stack setup command and got the below error -

  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

No, that is not the issue. GLIBC-2.26 most certainly provides the pthread_setname_np@@GLIBC_2.12 symbol (see this answer to understand how symbol versioning works).

You can verify that the symbol is indeed available in your GLIBC-2.26 like so:

$ 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

(Above command was executed on a system with GLIBC-2.19, but you'll get the same output on a system with GLIBC-2.26).

Now to what your real problem is: libHSrts.a(OSThreads.o) references pthread_setname_np (and likely other pthread_* symbols, but you are not linking with -pthread or -lpthread flag.

I don't know where to add this flag to GHC, but once you find that out, your problem will be solved.

这篇关于未定义的引用符号'pthread_setname_np @@ GLIBC_2.12'在OpenSuse42.3上的Haskell堆栈错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆