Mex C file generation Linker library error

조회 수: 1 (최근 30일)
Rich Osman
Rich Osman 2020년 2월 7일
댓글: Rich Osman 2020년 2월 10일
I'm trying to compile a C-source MEX file I received from a third party. I'm getting a linker error. It looks to me like it can't find zzz.lib, but I can't figure out where it's looking for it. yyy.c zzz.lib, zzz.h and zzz.dll are all in the same (current) folder.
>> mex yyy.C
Building with 'Microsoft Visual C++ 2019 (C)'.
Error using mex
Creating library zzz.lib and object zzz.exp
yyy.obj : error LNK2019: unresolved external symbol zzz referenced in function mexFunction
zzz.mexw64 : fatal error LNK1120: 1 unresolved externals
the linker error is clearly generated by MSVC, but I have no idea where it's looking for zzz.lib I can't figure out where it's trying to build the output files. It's not in C:\Users\Rich\source\repos which is the default for MSVC.
I'm confident that zzz.lib is good because I'm using it with C++ code under MSVC.
Any assistance or constructive suggestions appreciated.

채택된 답변

James Tursa
James Tursa 2020년 2월 10일
편집: James Tursa 2020년 2월 10일
Do you already have a zzz.lib file? Normally to get your mexFunction code to link to the library you simply include it as part of the mex command. E.g., if yyy.c and zzz.lib are in the current directory,
mex yyy.c zzz.lib
Or if zzz.lib is not in the current directly you could provide the path name as well.
  댓글 수: 1
Rich Osman
Rich Osman 2020년 2월 10일
I do already have zzz.lib. After a call with tech suport this morning I learned the answer:
mex -lzzz yyy.c
which yields 'MEX completed successfully.'
I've not tested the result as I have a half-dozen more to compile and some code to write, but I seem to be moving again. I'm not sure how I missed teh -l option.
Thanks for your reply.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by