Hi.
I have some problems compiling CUDA in matlab. I’m using a small scipt, which looks like this:
function compile(varargin)
!"%VS90COMNTOOLS%vsvars32.bat" & nvcc -c cudaKernel.cu
n=getenv('CUDA_LIB_PATH'); if n(1)=='"', n=n(2:end); end, if n(end)=='"', n=n(1:end-1);end
mex(['-L' n],'-lcudart','-lcufft','cudaKernel.obj',varargin{:});
When I run this I get the error:
>> compile cudaKernel.cpp
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
cudaKernel.cu
cudaKernel.cu(180): warning: variable "dreal" was declared but never referenced
cudaKernel.cu(180): warning: variable "dimagin" was declared but never referenced
tmpxft_00000804_00000000-3_cudaKernel.cudafe1.gpu
tmpxft_00000804_00000000-8_cudaKernel.cudafe2.gpu
cudaKernel.cu(180): warning: variable "dreal" was declared but never referenced
cudaKernel.cu(180): warning: variable "dimagin" was declared but never referenced
tmpxft_00000804_00000000-3_cudaKernel.cudafe1.cpp
tmpxft_00000804_00000000-13_cudaKernel.ii
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
cudaKernel.obj C:\DOCUME~1\MER\LOCALS~1\Temp\mex_dGc1FB\cudaKernel.obj
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __cdecl type_info::type_info(class type_info const &)" (??0type_info@@AEAA@AEBV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __cdecl type_info::operator=(class type_info const &)" (??4type_info@@AEAAAEAV0@AEBV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
Creating library C:\DOCUME~1\MER\LOCALS~1\Temp\mex_dGc1FB\templib.x and object C:\DOCUME~1\MER\LOCALS~1\Temp\mex_dGc1FB\templib.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
cudaKernel.mexw64 : fatal error LNK1169: one or more multiply defined symbols found
C:\PROGRA~1\MATLAB\R2008A\BIN\MEX.PL: Error: Link of 'cudaKernel.mexw64' failed.
??? Error using ==> mex at 207
Unable to complete successfully.
Error in ==> compile at 4
mex(['-L' n],'-lcudart','-lcufft','cudaKernel.obj',varargin{:});
In my cudaKernel.cpp I have a declaration of the function in cudaKernel.cu I want to call, with the extern “C” flag. I have no idea why this won’t work. Maybe it has something with the fact that I can’t compile in cmd. Using nvcc yealds:
c:\cuda\include\host_config.h(115) : fatal error C1083: Cannot open include file: ‘crtdefs.h’: No such file or directory
I’m in the dark here, and would appreciate any help.
Btw. The nvmex function won’t work either. When using nvmex I get:
>> nvmex -f nvmexopt_9.bat cudaKernel.cu
abdelali target arch: win64
C:\PROGRA~1\MATLAB\R2008A\BIN\NVMEX.PL: Error: Could not find specified options file
'nvmexopt_9.bat'.
??? Error using ==> nvmex at 206
Unable to complete successfully.
>> nvmex -f nvmexopts_9.bat cudaKernel.cu
abdelali target arch: win64
cudaKernel.cu
Z:/tekst/MATLAB/ISAR_Tests/cudaKernel.cu(180): warning: variable "dreal" was declared but never referenced
Z:/tekst/MATLAB/ISAR_Tests/cudaKernel.cu(180): warning: variable "dimagin" was declared but never referenced
tmpxft_000009fc_00000000-3_cudaKernel.cudafe1.gpu
tmpxft_000009fc_00000000-8_cudaKernel.cudafe2.gpu
Z:/tekst/MATLAB/ISAR_Tests/cudaKernel.cu(180): warning: variable "dreal" was declared but never referenced
Z:/tekst/MATLAB/ISAR_Tests/cudaKernel.cu(180): warning: variable "dimagin" was declared but never referenced
tmpxft_000009fc_00000000-3_cudaKernel.cudafe1.cpp
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
cudaKernel.obj
LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
C:\PROGRA~1\MATLAB\R2008A\BIN\NVMEX.PL: Error: Link of 'cudaKernel.mexw64' failed.
??? Error using ==> nvmex at 206
Unable to complete successfully.
Actually I don’t care which of them you know how to fix, ass long as one of them will work, I’ll be happy.