how to link mex?

1 次查看(过去 30 天)
Kate
Kate 2017-6-20
评论: Hannah 2017-8-29
hi,
my code is:
function build_cropRectanglesMex( cudaRoot )
%build_cropRectanglesMex builds package cropRectanglesMex
%
% INPUT:
% cudaRoot - path to the CUDA installation
% Anton Osokin, firstname.lastname@gmail.com, May 2015
if ~exist('cudaRoot', 'var')
cudaRoot = 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\' ;
end
nvccPath = fullfile(cudaRoot, 'bin', 'nvcc.exe')
if ~exist(nvccPath, 'file')
error('NVCC compiler was not found!');
end
root = fileparts( mfilename('fullpath') );
% compiling
compileCmd = [ '"', nvccPath, '"', ...
' -c ', fullfile(root,'cropRectanglesMex.cu'), ...
' -I"', fullfile( matlabroot, 'extern', 'include'), '"', ...
' -I"', fullfile( matlabroot, 'toolbox', 'distcomp', 'gpu', 'extern', 'include'), '"', ...
' -I"', fullfile( cudaRoot, 'include'), '"', ...
' -DNDEBUG -DENABLE_GPU', ...
' -Xcompiler', ' -fPIC', ...
' -o "', fullfile(root,'cropRectanglesMex.o'), '"'];
system( compileCmd );build_cropRectanglesMex
% linking
mopts = {'-outdir', root, ...
'-output', 'cropRectanglesMex', ...
['-L', fullfile(cudaRoot, 'lib','x64')], ...
'cudart.lib', '-nppi', '-nppc', 'mwgpu', ...
'-largeArrayDims', ...
fullfile(root,'cropRectanglesMex.o') };
mex(mopts{:}) ;
delete( fullfile(root,'cropRectanglesMex.o') );
I get this error:
Error using mex
Unknown file extension ''.
Error in build_cropRectanglesMex (line 37)
mex(mopts{:}) ;
I believe the code is for linking in Linux. How can I do an equivalent linking for Windows?
  5 个评论
Joss Knight
Joss Knight 2017-6-22
Using mexcuda you don't need to try to link mwgpu because that is done for you. And libraries are linked using the -l option; so you need -lnppi not -nppi.
Hannah
Hannah 2017-8-29
Kate, did you ever figure out the LNK2019 error when compiling with mexcuda? I am having the same issue.

请先登录,再进行评论。

回答(1 个)

li zhaoliang
li zhaoliang 2017-7-18

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by