unresolved external symbol mxDestroyArray referenced in function mexFunction

Hi All I am integrating MATLAB to run cuda prog via MEX interface. It runs fine with following combination 1.MATLAB 64bit 2012 r2 2.Windows 64bit OS But when i tried same thing on MATLAB 2008 32 bit on windows 64 bit version it gives following linking error
vecsum.obj : error LNK2019: unresolved external symbol mxDestroyArray referenced in function mexFunction vecsum.obj : error LNK2019: unresolved external symbol mxCreateDoubleScalar referenced in function mexFunction vecsum.obj : error LNK2019: unresolved external symbol mexPrintf referenced in function mexFunction vecsum.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function mexFunction vecsum.mexw32 : fatal error LNK1120: 4 unresolved externals
I have set the nvmexopts64.bat LINK path like this
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win32\microsoft
set LINKER=link
set LINKFLAGS=/dll /export:%ENTRYPOINT% /MAP /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /implib:%LIB_NAME%.x /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/DEBUG /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@
==================
i also put the additional lib path and lib like libmex.lib libmx.lib libmat.lib to the command line like this " nvmex -f nvmexopts64.bat vecsum.cu -IC:\CUDA\include -LC:\CUDA\lib\x64 -lcufft -lcudart –lcuda -LPathto the lib dir of matlab -I path to the include dir of matlab -llibmex -llibmx -llibmat"
But it did not work

回答(1 个)

I'm assuming you have two versions of MATLAB on your 64-bit machine - one 32-bit, the other 64-bit. From what I understand, you are able to compile your MEX-files on the 64-bit MATLAB, but not on 32-bit MATLAB? Did you run 'mex -setup" on the 32-bit MATLAB before compiling? You will need to run "mex -setup" every time you switch between the two installations.

4 个评论

I have Microsoft Visual C++ 2005 in C:\Program Files (x86)\Microsoft Visual Studio 8 which is 32 bit version .do i need to install 64 bit version of the same .I thinh mex function are being called via nvcc--> c -->matlab linker process. somehow nvcc doesnot called a 32 bit c lib which internally call matlab mex interface I had integrated CUDA file with matlab earlier on 64 bit machine with all three software are of 64 bit .it was working there
If you have 64-bit MATLAB installed, you do need to link against all 64-bit libraries and use a 64-bit compiler. Note that Visual Studio itself is always a 32-bit application (and is installed in "Program Files (x86)"), but you need to make sure that the x64 Compilers package is selected at installation.
That mean the during installation of Visual studio i need to make sure the 64 bit compiler package is to be installed

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by