WAF链接器错误问题

时间:2013-08-10 14:45:28

标签: build build-process waf

我有2个文件1)simple1.cu 2)test.cpp。我正在尝试使用WAF编译和链接这些文件.wscript文件如下所示。

def options(opt):
   opt.load('compiler_cxx')

def configure(cnf):
   cnf.load('compiler_cxx')

def build(bld):
    bld(
        name='b1',
        features='cxx',
        rule='/usr/local/cuda/bin/nvcc -arch=sm_35 -dc ${SRC}',
        source='simple1.cu',
        target='simple1.o')
    bld(
        name='r1',
        features='cxx',
        rule='/usr/local/cuda/bin/nvcc -arch=sm_35 -dlink ${SRC} -o ${TGT} -lcudadevrt',
        includes=['build'],
        source='simple1.o',
        target='link.o',
        after='b1')
    bld(
        name='abc',
        features='cxx',
        rule='g++ -c ${SRC}',
        source='test.cpp',
        includes=['build'],
        after='r1')

我正在使用cuda单独的编译选项。现在使用上面的文件,我可以生成3个对象文件link.o simple1.o和test.o

但是当我想将它们与以下内容联系起来时。

bld(
        features='cxxprogram',
        rule='g++ ${SRC} -o ${TGT} -L/usr/local/cuda/lib64/ -lcudart',
        includes=['build'],
        source=['simple1.o','link.o','test.o'],
        target='somex')

我收到以下错误

未找到来源:bld中的'test.o'(feature = ['cxxprogram'],idx = 4,_name ='somex',meths = ['create_task_macapp','create_task_macplist','process_rule' ,'process_source'],prec = defaultdict(,{}),包括= ['build'],source = ['simple1.o','link.o','test.o']

如果我在终端上手动链接文件和命令跟随命令它工作正常(我将能够创建可执行文件并执行它)

g++ build/link.o build/simple1.o build/test.o -o simple -L/usr/local/cuda/lib64/ -lcudart

请帮忙。

1 个答案:

答案 0 :(得分:0)

能够用以下方法解决..我认为规则“g ++ -c $ {SRC}”会生成test.o但它不是..感谢托马斯在google小组中回答我同样的问题。< / p>

bld(
        features='cxx',
        rule='${NVCC} ${CUDAFLAGS} ${CXXFLAGS} ${CPPPATH_ST:INCPATHS} ${DEFINES_ST:DEFINES} ${CXX_SRC_F} ${SRC} ${CXX_TGT_F} ${TGT}',
        source='simple1.cu',
        target='simple1.o',
        cxxflags=['-arch=sm_35','-dc'],
        includes=['build'])
    bld(
        features='cxx',
        rule='${NVCC} ${CXXFLAGS} ${SRC} ${CXXLNK_TGT_F} ${TGT} -lcudadevrt',
        includes=['build'],
        source='simple1.o',
        target='link.o',
        cxxflags=['-arch=sm_35', '-dlink'],
        stlib='cudadevrt')
    bld(
        features='cxx',
        rule='g++ -c ${SRC} -o ${TGT}',
        source='test.c',
        target='test.o',
        includes=['build'])
    bld(
        features='cxxprogram',
        rule='g++ ${SRC} -o ${TGT} -L/usr/local/cuda/lib64/ -lcudart',
        includes=['build'],
        source=['simple1.o','link.o','test.o'],
        target='somex')