You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

mpicc编译含MPI/OpenACC的igraph代码时libquadmath链接失败求助

问题:mpicc编译igraph代码时找不到libquadmath.0.dylib

我需要编译一个使用MPI和OpenACC的igraph代码文件,以igraph示例“sparsemat2.c”测试时,用gcc可正常编译,但用mpicc编译失败。

编译命令及报错

$ gcc sparsemat2.c -I/usr/local/include/igraph -o sparsemat2 -ligraph
$ mpicc sparsemat2.c -I/usr/local/include/igraph -o sparsemat2 -ligraph
ld: file not found: @rpath/libquadmath.0.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$

系统信息

MacBook Pro OSX 12.6.3
$ mpicc --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$

疑问

请问libquadmath.0.dylib是否仅关联gcc?如何让mpicc链接到该库?


解答

  1. libquadmath与GCC的关联
    libquadmath是GCC专属的支持四精度浮点数运算的库,Clang(你的mpicc实际调用的是Apple Clang)本身不自带这个库,也不会默认依赖它。出现这个问题是因为你当前使用的igraph库是用GCC编译的,编译时链接了libquadmath,导致用Clang系的mpicc链接时找不到该库。

  2. 让mpicc链接到libquadmath的方法

  • 手动指定链接库及路径:修改编译命令,添加-lquadmath参数,并通过-L指定GCC库的路径。首先用gcc -print-search-dirs查看GCC的库路径,找到包含libquadmath的目录,然后调整命令:
    mpicc sparsemat2.c -I/usr/local/include/igraph -o sparsemat2 -ligraph -lquadmath -L/usr/local/lib/gcc/[你的GCC版本号]
    
    例如,如果GCC版本是12.2.0,路径可能是/usr/local/lib/gcc/12。
  • 重新用Clang编译igraph:如果长期用mpicc编译代码,建议重新用Apple Clang编译igraph库,这样编译出的库不会依赖GCC的libquadmath,后续链接时就不会出现该问题。

内容的提问来源于stack exchange,提问作者Mark Bower

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 18:40:20