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

在Linux构建可用于QNX 7.1的Boost库(Conan构建报错求助)

问题:Linux交叉编译Boost for QNX 7.1时Conan构建libbacktrace失败

错误日志

Cross-build from 'Linux:x86_64' to 'Neutrino:x86_64'
Installing (downloading, building) binaries...
b2/4.9.3: Already installed!
bzip2/1.0.8: Already installed!
libbacktrace/cci.20210118: WARN: Build folder is dirty, removing
checking for gcc... qcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/home/user/.conan/data/libbacktrace/cci.20210118/_/_/build/487843ee4e66cda082d78c49de1887320a778ff1/build-debug':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
libbacktrace/cci.20210118: 
libbacktrace/cci.20210118: ERROR: Package '487843ee4e66cda082d78c49de1887320a778ff1' build failed
libbacktrace/cci.20210118: WARN: Build folder /home/user/.conan/data/libbacktrace/cci.20210118/_/_/build
        '

我的Conan配置

include(default)
[settings]
os=Neutrino
os.version=7.1
arch=x86_64

compiler=qcc
compiler.libcxx=cxx
compiler.version=8.3

os_build=Linux
arch_build=x86_64
build_type=Debug
[options]
[build_requires]
[env]
CC=qcc
CXX=q++
CONAN_CMAKE_TOOLCHAIN_FILE=/path/to/qnx.cmake
CMAKE_CXX_COMPILER=$QNX_HOST/usr/bin/q++
CMAKE_C_COMPILER=$QNX_HOST/usr/bin/qcc
CXX=$QNX_HOST/usr/bin/q++
LD_LIBRARY_PATH=[$QNX_HOST/usr/lib]
MAKEFLAGS=-I$QNX_TARGET/usr/include

解决方案

这个错误的核心是libbacktrace的configure脚本尝试运行交叉编译生成的QNX二进制文件,但Linux主机无法执行QNX程序,导致检测失败。以下是具体修复步骤:

1. 给libbacktrace指定交叉编译host参数

在Conan配置的[env]部分添加,明确告知configure脚本目标平台:

CONAN_CONFIGURE_ARGS="--host=x86_64-pc-nto-qnx7.1.0"

注:x86_64架构的QNX目标triple通常为x86_64-pc-nto-qnx7.1.0,如果是其他架构需要对应调整。

2. 修复环境变量错误

  • 删除原MAKEFLAGS=-I$QNX_TARGET/usr/include,把包含路径参数转移到编译器环境变量中:
    CFLAGS="-I$QNX_TARGET/usr/include"
    CXXFLAGS="-I$QNX_TARGET/usr/include"
    
  • 确保运行Conan前已通过source /path/to/qnx710/qnxsdp-env.sh正确导出QNX_HOST和QNX_TARGET环境变量。

3. 验证CMake工具链配置

检查qnx.cmake是否包含以下关键配置:

set(CMAKE_SYSTEM_NAME Neutrino)
set(CMAKE_SYSTEM_VERSION 7.1)
set(CMAKE_C_COMPILER_TARGET x86_64-pc-nto-qnx7.1.0)
set(CMAKE_CXX_COMPILER_TARGET x86_64-pc-nto-qnx7.1.0)
set(CMAKE_CROSSCOMPILING ON)

4. 强制跳过二进制运行检测

如果以上步骤无效,可在CONAN_CONFIGURE_ARGS中添加跳过检测的参数:

CONAN_CONFIGURE_ARGS="--host=x86_64-pc-nto-qnx7.1.0 --disable-checking"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 04:33:13