2013-08-10 2 views
0

2 개의 파일이 있습니다. 1) simple1.cu 2) test.cpp. 컴파일 및 WAF를 사용하여 이러한 파일을 연결하려고합니다. wscript 파일은 아래와 같습니다.WAF 링커 오류 문제

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

그들을 링크 할 때 다음과 같은 얻을 오류

소스를 찾을 수 없습니다 'test.o'를 BLD (기능 = 'cxxprogram', IDX = 4 _name = 'somex'meths가 = 'create_task_macapp', 'create_task_macplist', 'process_rule'에 , 'process_source'], prec = defaultdict (, {}), include = [ 'build'], 소스 = [ 'simple1.o', 'link.o', 'test.o']

내가 그것을 잘 작동 터미널에서 명령 다음 명령을 사용하여 수동 함께 파일을 연결하면3210

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

도와주세요 (내가 실행 파일을 생성하고 실행 할 수 있습니다).

답변

0

다음과 같이 해결할 수있었습니다. "g ++ -c $ {SRC}"규칙이 test.o를 생성 할 것이라고 생각했지만 그게 아니 었습니다. 같은 질문에 대해 Google 그룹에서 저에게 응답 한 thomas에게 감사드립니다.

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