0

I have this project with the following file structure :

|-- CG.cu  
|-- Makefile  
|-- examples  
| |-- ex2.h  
|   |-- ex3.h  
|   |-- mmio.c  
|   |-- mmio.h  
|   |-- nos4.mtx  
|-- util.h  

CG.cu is my main program (A Conjugate Gradient solver) i have some help functions in util.h and then i have some hardcoded examples in ex2.h and ex3.h (I know it's bad practice, but it's okay for now) the problem is that ex3.h need mmio.c,mmio.h and nos4.mtx to load in the example.

So basically the flow is : CG.cu -> ex3.h -> mmio.h (mmio.c) The compiler (NVCC : later being ported for cuda) complains about undefined references for the mmio functions.

Currently my Makefile looks like this:

main: CG.cu util.h
      NVCC -o main CG.cu

and GC.cu uses #include "examples/ex3.h", and ex3.h uses #include "mmio.h"

Can you help me?

4

1 回答 1

0

您需要先编译 mmio.c,然后将 CG.cu 与生成的目标文件链接。您也可以一步完成:

mian: CG.cu util.h NVCC -o main CG.cu mmio.c
于 2012-04-16T06:20:01.373 回答