Question

I have 2 files 1) simple1.cu 2) test.cpp. I am trying to compile and link these files using WAF.. The wscript file looks as below.

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')

I am using the cuda separate compilation option. Now with the above file i am able to generate 3 objects files link.o simple1.o and test.o

but when i want to link them with the following..

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')

i get the following error

source not found: 'test.o' in bld(features=['cxxprogram'], idx=4, _name='somex', meths= ['create_task_macapp', 'create_task_macplist', 'process_rule', 'process_source'], prec=defaultdict(, {}), includes=['build'], source=['simple1.o', 'link.o', 'test.o']

If i link the files manually together with the command following command on the terminal it works fine (i will be able to create the executable and execute it)

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

Please help.

Was it helpful?

Solution

Was able to solve with the following.. i thought the rule "g++ -c ${SRC}" would generate test.o but it wasnt.. Thanks to thomas who answered me in the google groups for same question.

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')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top