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

conda-build无法识别库:构建INSurVeyor包遇多类报错求助

Conda-Build构建INSurVeyor包的问题排查与解决

问题背景

首次使用conda-build构建INSurVeyor包时,遭遇多类异常:构建阶段出现rpath路径警告、静态库格式未知、二进制无程序头提示;运行生成的可执行文件时,触发符号查找错误:

symbol lookup error: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined symbol: ffi_type_pointer, version LIBFFI_BASE_7.0

相关配置文件

build.sh

CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE="${RECIPE_DIR}/cross-linux.cmake")
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$PREFIX ${CMAKE_PLATFORM_FLAGS[@]} .
make
cp surveyor.py random_pos_generator.py $PREFIX/bin/
cp add_filtering_info call_insertions clip_consensus_builder dc_remapper filter normalise reads_categorizer $PREFIX/bin/

meta.yaml

{% set name = "insurveyor" %}
{% set version = "1.0.1" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://github.com/kensung-lab/INSurVeyor/archive/refs/tags/1.0.2.tar.gz
  sha256: 33c85157892d3256abc96bb2a9053f05da9dcf55befeed720e965577db0b78b5

build:
  skip: True # [not linux]
  number: 0

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake >=3.5
    - autoconf ==2.69
  host:
    - libcurl
    - bzip2
    - xz
    - zlib
    - libdeflate
    - openssl 
    - htslib >=1.13
  run:
    - python
    - numpy >=1.21.2

test:
  source_files:
    - demo/

about:
  home: https://github.com/kensung-lab/INSurVeyor
  summary: 'An insertion caller for Illumina paired-end WGS data.'
  description: XXX
  license: GPL-3.0-only
  license_file: LICENSE

extra:
  recipe-maintainers:
    - Mesh89

问题根源

  1. 符号冲突:系统libp11-kit.so.0依赖的libffi版本与conda环境中的版本不匹配,动态链接时无法找到对应版本的符号ffi_type_pointer。
  2. rpath配置缺失:手动复制二进制文件到$PREFIX/bin,未通过make install让CMake自动配置rpath,导致二进制优先链接系统库而非conda环境内的依赖库,加剧兼容性问题。
  3. 静态库与二进制构建不规范:CMake未正确处理静态库链接,且手动复制二进制跳过了conda-build的标准化处理流程,引发格式、程序头类警告。

解决步骤

1. 标准化二进制安装流程

修改build.sh,用make install替代手动复制二进制文件,让CMake自动管理安装路径与rpath:

CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE="${RECIPE_DIR}/cross-linux.cmake")
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX ${CMAKE_PLATFORM_FLAGS[@]} .
make
make install
cp surveyor.py random_pos_generator.py $PREFIX/bin/

若原项目CMakeLists.txt未配置install指令,需添加如下内容:

# 遍历所有编译生成的二进制文件,配置安装路径
foreach(BIN add_filtering_info call_insertions clip_consensus_builder dc_remapper filter normalise reads_categorizer)
    install(TARGETS ${BIN} DESTINATION bin)
endforeach()

2. 强制使用conda环境内的libffi

在meta.yaml的依赖中添加libffi,确保链接的是conda管理的版本:

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake >=3.5
    - autoconf ==2.69
  host:
    - libcurl
    - bzip2
    - xz
    - zlib
    - libdeflate
    - openssl 
    - htslib >=1.13
    - libffi
  run:
    - python
    - numpy >=1.21.2
    - libffi

3. 修复静态库链接问题

  • 确认项目中静态库为Linux ELF格式,第三方库需下载对应平台版本。
  • 在CMake命令中添加-DCMAKE_PREFIX_PATH=$PREFIX,引导CMake优先查找conda环境内的库文件。

4. 隔离构建环境

创建干净的conda构建环境,避免现有环境依赖干扰:

conda create -n insurveyor_build conda-build compilers cmake -y
conda activate insurveyor_build
conda build .

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 03:55:25