gpt4 book ai didi

cross-compiling - 如何将交叉编译器与 Scons 一起使用?

转载 作者:行者123 更新时间:2023-12-04 12:12:47 25 4
gpt4 key购买 nike

遵循建议 on the Scons FAQ来自 old mailing list thread ,我已经建立了一个非常简单的 SConstructSConscript我认为会构建一个示例应用程序,但出现错误:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
nios2-linux-gnu-g++ -o src/bin/example/example.o -c src/bin/example/example.cpp
sh: nios2-linux-gnu-g++: command not found
scons: *** [src/bin/example/example.o] Error 127
scons: building terminated because of errors.

啊。我的 SConstruct文件:
import os

env_options = {
"CC" : "nios2-linux-gnu-gcc",
"CXX" : "nios2-linux-gnu-g++",
"LD" : "nios2-linux-gnu-g++",
"AR" : "nios2-linux-gnu-ar",
"STRIP" : "nios2-linux-gnu-strip",
"PATH" : os.environ['PATH']
}

env = Environment(**env_options)
Export('env')

env.SConscript("src/bin/example/SConscript")

以及它调用的 SConscript:
Import('env')

env.Program("example", ["example.cpp"])

以下是我认为 env.Dump() 的相关部分(如果有什么遗漏,请告诉我):
{ 'AR': 'nios2-linux-gnu-ar',
'CC': 'nios2-linux-gnu-gcc',
'CCCOM': '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES',
'CCFLAGS': [],
'CCVERSION': '4.8.2',
'CFILESUFFIX': '.c',
'CFLAGS': [],
'CPPDEFPREFIX': '-D',
'CPPDEFSUFFIX': '',
'CPPSUFFIXES': [ '.c',
'.C',
'.cxx',
'.cpp',
'.c++',
'.cc',
'.h',
'.H',
'.hxx',
'.hpp',
'.hh',
'.F',
'.fpp',
'.FPP',
'.m',
'.mm',
'.S',
'.spp',
'.SPP',
'.sx'],
'CXX': 'nios2-linux-gnu-g++',
'CXXCOM': '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES',
'CXXFILESUFFIX': '.cc',
'CXXFLAGS': [],
'CXXVERSION': '4.8.2',
'HOST_ARCH': None,
'HOST_OS': None,
'PATH': '/home/chockey/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/chockey/bin/altera/13.1/quartus/bin:/home/chockey/bin/altera/13.1/quartus/sopc_builder/bin:/home/chockey/bin/altera/13.1/nios2eds/bin:/home/chockey/bin/altera/13.1/nios2eds/sdk2/bin:/home/chockey/bin/altera/13.1/nios2eds/bin/gnu/H-i686-pc-linux-gnu/bin',
'TOOLS': [ 'default',
'gnulink',
'gcc',
'g++',
'gfortran',
'gas',
'ar',
'filesystem',
'm4',
'lex',
'yacc',
'rpcgen',
'jar',
'javac',
'javah',
'rmic',
'dvipdf',
'gs',
'tar',
'zip'],

这些工具肯定存在于第一个路径条目(作为符号链接(symbolic link),如果这很重要,但我尝试将完整路径添加到工具链,这似乎没有改变任何东西):
/home/chockey/bin/nios2-linux-gnu-addr2line@   /home/chockey/bin/nios2-linux-gnu-gcov@
/home/chockey/bin/nios2-linux-gnu-ar@ /home/chockey/bin/nios2-linux-gnu-gdb@
/home/chockey/bin/nios2-linux-gnu-as@ /home/chockey/bin/nios2-linux-gnu-gprof@
/home/chockey/bin/nios2-linux-gnu-c++@ /home/chockey/bin/nios2-linux-gnu-ld@
/home/chockey/bin/nios2-linux-gnu-c++filt@ /home/chockey/bin/nios2-linux-gnu-nm@
/home/chockey/bin/nios2-linux-gnu-cpp@ /home/chockey/bin/nios2-linux-gnu-objcopy@
/home/chockey/bin/nios2-linux-gnu-elfedit@ /home/chockey/bin/nios2-linux-gnu-objdump@
/home/chockey/bin/nios2-linux-gnu-g++@ /home/chockey/bin/nios2-linux-gnu-ranlib@
/home/chockey/bin/nios2-linux-gnu-gcc@ /home/chockey/bin/nios2-linux-gnu-readelf@
/home/chockey/bin/nios2-linux-gnu-gcc-4.7.3@ /home/chockey/bin/nios2-linux-gnu-size@
/home/chockey/bin/nios2-linux-gnu-gcc-ar@ /home/chockey/bin/nios2-linux-gnu-sprite@
/home/chockey/bin/nios2-linux-gnu-gcc-nm@ /home/chockey/bin/nios2-linux-gnu-strings@
/home/chockey/bin/nios2-linux-gnu-gcc-ranlib@ /home/chockey/bin/nios2-linux-gnu-strip@

如何让 scons 找到我的工具链?

最佳答案

您快到了。您正在添加您的 PATH到 SCons 构建环境而不是 ENV施工环境关键:

import os

env_options = {
"CC" : "nios2-linux-gnu-gcc",
"CXX" : "nios2-linux-gnu-g++",
"LD" : "nios2-linux-gnu-g++",
"AR" : "nios2-linux-gnu-ar",
"STRIP" : "nios2-linux-gnu-strip",
}

env = Environment(**env_options)
env.Append(ENV = {'PATH' : os.environ['PATH']})
Export('env')

关于cross-compiling - 如何将交叉编译器与 Scons 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23898584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com