Mac系统suitesparse 安装错误【ld: warning: ignoring file ‘/opt/homebrew/Cellar/mpfr/4.2.1/lib/libmpfr.6.dyli



SuiteSparse网址:DrTimothyAldenDavis/SuiteSparse: The official SuiteSparse library: a suite of sparse matrix algorithms authored or co-authored by Tim Davis, Texas A&M University. (github.com)

主要编译命令:

    mkdir -p build && cd build
    cmake ..
    cmake --build .
    sudo cmake --install .
  

一、arm64架构不匹配

错误信息:

-macosx_version_min has been renamed to -macos_version_min ld: warning: ignoring duplicate libraries: ‘-lgcc’, ‘-lgcc_s.1.1’ ld: warning: ignoring file ‘/Desktop/SuiteSparse-dev/build/AMD/CMakeFiles/AMD.dir/Source/amd_1.c.o’: found architecture ‘arm64’, required architecture ‘x86_64’

解决:

cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 ..

二、CholMOD编译问题

Desktop/SuiteSparse-dev/SuiteSparse_config/SuiteSparse_config.h:684:6: error: expected ‘)’ void SUITESPARSE_BLAS_DGEMV( Desktop/SuiteSparse-dev/SuiteSparse_config/SuiteSparse_config.h:593:37: note: expanded from macro ‘SUITESPARSE_BLAS_DGEMV’ #define SUITESPARSE_BLAS_DGEMV SUITESPARSE_BLAS ( dgemv , DGEMV )

CholMOD编译有问题,解决方案参考:Issues · DrTimothyAldenDavis/SuiteSparse (github.com)

具体操作,在CmakeLists.txt中添加:

# 添加 BLAS_UNDERSCORE 定义到 C 编译器标志
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBLAS_UNDERSCORE")

# 添加 BLAS_UNDERSCORE 定义到 C++ 编译器标志
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBLAS_UNDERSCORE")

三、gmp和mpfr架构不匹配

ld: warning: ignoring file ‘/opt/homebrew/Cellar/mpfr/4.2.1/lib/libmpfr.6.dylib’: found architecture ‘arm64’, required architecture ‘x86_64’

ld: warning: ignoring file ‘/opt/homebrew/Cellar/gmp/6.3.0/lib/libgmp.10.dylib’: found architecture ‘arm64’, required architecture ‘x86_64’

需要重新下载x86_64架构的包,那么需要重新下载inter架构的intel,下载命令如下:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

需要先确保新的 Homebrew 路径在你的 PATH 中。编辑 ~/.zshrc 并添加:

export PATH="/usr/local/bin:$PATH"

这个路径保证brew首先用/usr/local下的针对intel的brew包,然后再用下面的命令下载x86的包:

arch -x86_64 brew install mpfr gmp

Note:

  • 完成上面步骤后,需要删掉build重新构建SuiteSparse

  • 记得添加路径:

    export CPPFLAGS="-I/usr/local/opt/gmp/include $CPPFLAGS"
    export LDFLAGS="-L/usr/local/opt/gmp/lib $LDFLAGS"
    
  • 28
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值