0

我有 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”(功能=['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

请帮忙。

4

1 回答 1

0

能够解决以下问题..我认为规则“g++ -c ${SRC}”会生成test.o,但它不是..感谢在谷歌群组中回答我相同问题的托马斯。

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')
于 2013-08-14T02:44:32.183 回答