I’m new here and have a question about compiling my project.
Originally, it was a package of .c files, where a mexfile for use in Matlab could be compiled with an script.
I now want to convert the corefunctions of the package to CUDA. I wrote a Caller-.cu (Memeryallocation, Grid/Block-Def., Kernelcall) and a Kernel-.cu file. The CUDA-function should now be called from one of the .c files.
“bool cbct_back(bunch of paramter)” is now defined in the Caller-.cu.
In the .c file with the call I defined “extern bool cbct_back(params);” (which is in the cu-file) at the beginning and the funtion should be called in the code of this file.
Now I modified the Makefile from the “MATLAB plug-in for CUDA” available on the Nvidia-Site. In detail,
I’m letting first the .cu files be compiled, that works out right:
(NVMEX) -f nvopts.sh < (INCLUDEDIR) (INCLUDELIB) *.cu
The the c-files are done by the mex-compiler co-using gcc, also ok:
/usr/local/matlab/extern/…/bin/mex CC=gcc -v CFLAGS=’$(CFLAGS)’ -output cbct_mex.mexa64 -I/usr/local/matlab/extern/include -DMATLAB_HOST -DMmex -UUse_plpa -v -DNeed_cbct_mex_gateway *.c
But at the end of this, the Makefile tries to put the files together but utilizes only the former c-files (now o-files) and I get an error:
-> gcc -O -pthread -shared -Wl,–version-script,/usr/local/matlab/extern/lib/glnxa64/mexFunction.map -Wl,–no-undefined -o “cbct_mex.mexa64” <all the .o-files> -Wl,-rpath-link,/usr/local/matlab/bin/glnxa64 -L/usr/local/matlab/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
[i]cbct,pd1,back,t.o: In function
cbct_pd1_back_init': cbct,pd1,back,t.c:(.text+0x5ed): undefined reference to cbct_back’
collect2: ld gab 1 als Ende-Status zurÃ¼ck
mex: link of ' "cbct_mex.mexa64"' failed.[/i]
How can I tell the Makefile to also link the formerly nvcc-compiled cu-files in this step? I’m sure that this is the reason the cbct_back function is not found. Any help would be ppreciated. Sadly, not much is found about compiling c+cu to mex on the web where I could have a look at an example.