MEX error LNK2019: unresolved external symbol

61 ビュー (過去 30 日間)
maarten vaandrager
maarten vaandrager 2014 年 1 月 8 日
コメント済み: Thomas 2022 年 10 月 18 日
Hi everybody,
I need to fix a matlab program that incorporates C code compiled to a mex function. It is likely that the mex functions stopped working when updating Matlab from 32bit to 64bit.
when trying to recompile the c code into a mex file I get the following error:
mex qpip.c
qpip.obj : error LNK2019: unresolved external symbol qpip_sub referenced in function mexFunction
qpip.obj : error LNK2019: unresolved external symbol dcopy referenced in function mexFunction
qpip.mexw64 : fatal error LNK1120: 2 unresolved externals
I did not write the program myself but I should have all the necessary files. The qpip_sub.c and qpip_sub.h and some other files are in the same folder. The dcopy function seems to be part of the the BLAS linear algebra package but I only seem to have blasmap.h.
Any ideas what is going wrong? Thanks for the help!
(using MSVS2010, MATLAB R2011b, 64bit Windows 7)

採用された回答

Jorik
Jorik 2014 年 1 月 9 日
編集済み: Jorik 2014 年 1 月 9 日
The unresolved external symbols errors indicate that during the link-stage of compiling the MEX-file, these symbols are not available.
For the qpip_sub, this most probably means, you need to add the source-file with that function to the MEX command.
For the dcopy (a BLAS function?), this most probably means, you want to link to the BLAS library that is shipping with MATLAB, see this documentation page for more information regarding compiling MEX-files that use BLAS functions.
  3 件のコメント
maarten vaandrager
maarten vaandrager 2014 年 1 月 9 日
Problem solved :) As explained in the documentation I needed to add the BLAS and LAPACK libraries that come with matlab to the mex command:
location = 'C:\Program Files\MATLAB\R2011b\extern\lib\win64\microsoft\';
lapacklib = [location 'libmwlapack.lib'];
blaslib = [location 'libmwblas.lib'];
mex('-v', '-largeArrayDims', 'qpip.c','qpip_sub.c', blaslib, lapacklib)
Thanks a lot Jorik!
Matthew Gaddes
Matthew Gaddes 2015 年 5 月 6 日
Compiling all the files in one command helped me - thank you!

サインインしてコメントする。

その他の回答 (1 件)

Ingo Hermann
Ingo Hermann 2017 年 11 月 8 日
I have a similar problem with the error:
mex mexFitFunctions.c
Building with 'Microsoft Windows SDK 7.1 (C)'.
Error using mex
LINK : error LNK2001: unresolved external symbol mexFunction
mexFitFunctions.lib : fatal error LNK1120: 1 unresolved externals
I tried the stuff from aboth but get the same error.
  3 件のコメント
BABANBHAIGARI SHAFIULLAH
BABANBHAIGARI SHAFIULLAH 2020 年 3 月 13 日
I am facing similar error, did you get the answer for this. Please let me know how to resolve this issue.
Thomas
Thomas 2022 年 10 月 18 日
Hi ! I am updating this post as I am facing the same issue as Ingo.
Did someone manage to get through it ?
Thank you

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeIntroduction 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