LNK2019 error when using mex

6 views (last 30 days)
J Fromageau
J Fromageau on 14 Feb 2013
Hello,
I'm trying to compile an old program to have it working with the 64bit matlab version we have.
It used to create a dll, but I suppose it should create a .mexw64 now.
I've got multiple LNK2019 errors and I can't find a solution.
I think I linked correctly all the needed libraries, even forced it manually with the following command:
mex -v -IE:\Jeremie\MATLAB\Maria\algorithme_versionC\tdelay\tdelay_3D tdelay_3D.cpp libfftw3-3.lib libfftw3f-3.lib
But I always receive this message. Does anyone have a clue?
Regards
Jeremie
-> Default options filename found in C:\Users\Jeremie\AppData\Roaming\MathWorks\MATLAB\R2010b
-> Options file = C:\Users\Jeremie\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
MATLAB = C:\Program Files\MATLAB\R2010b
-> COMPILER = cl
-> Compiler flags:
COMPFLAGS = /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD
OPTIMFLAGS = /O2 /Oy- /DNDEBUG
DEBUGFLAGS = /Z7
arguments = -IE:\Jeremie\MATLAB\Maria\algorithme_versionC\tdelay\tdelay_3D
Name switch = /Fo
-> Pre-linking commands =
-> LINKER = link
-> Link directives:
LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2010b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 -lkernel32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\templib.x" /MAP:"tdelay_3D.mexw64.map"
LINKDEBUGFLAGS = /debug /PDB:"tdelay_3D.mexw64.pdb"
LINKFLAGSPOST =
Name directive = /out:"tdelay_3D.mexw64"
File link directive =
Lib. link directive =
Rsp file indicator = @
-> Resource Compiler = rc /fo "mexversion.res"
-> Resource Linker =
----------------------------------------------------------------
--> cl -IE:\Jeremie\MATLAB\Maria\algorithme_versionC\tdelay\tdelay_3D /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\tdelay_3D.obj -I"C:\Program Files\MATLAB\R2010b"\extern\include /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 tdelay_3D.cpp
tdelay_3D.cpp
tdelay_3D.cpp(123) : warning C4101: 'Es' : unreferenced local variable
Contents of C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\mex_tmp.rsp:
C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\tdelay_3D.obj libfftw3-3.lib libfftw3f-3.lib
--> link /out:"tdelay_3D.mexw64" /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2010b\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 -lkernel32 user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\templib.x" /MAP:"tdelay_3D.mexw64.map" @C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\mex_tmp.rsp
LINK : warning LNK4044: unrecognized option '/lkernel32'; ignored
Creating library C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\templib.x and object C:\Users\Jeremie\AppData\Local\Temp\mex_KgKv6u\templib.exp
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_cleanup referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_free referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_destroy_plan referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_execute referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_plan_dft_c2r_1d referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_plan_dft_r2c_1d referenced in function mexFunction
tdelay_3D.obj : error LNK2019: unresolved external symbol __imp_fftw_malloc referenced in function mexFunction
tdelay_3D.mexw64 : fatal error LNK1120: 7 unresolved externals
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Link of 'tdelay_3D.mexw64' failed.
  1 Comment
Kaustubha Govind
Kaustubha Govind on 14 Feb 2013
Should you need to specify the location of the two static libraries? Also, you may need to use the -l option to specify libraries:
>> mex -v -IE:\Jeremie\MATLAB\Maria\algorithme_versionC\tdelay\tdelay_3D tdelay_3D.cpp -llibfftw3-3.lib -llibfftw3f-3.lib

Sign in to comment.

Answers (1)

J Fromageau
J Fromageau on 15 Feb 2013
Edited: J Fromageau on 15 Feb 2013
Hello,
Well my question was partly answered so I might to an update if it can help later.
1) I had a copy of libfftw3-3.lib in another folder, which was probably read during my compilation, I suspect it was the 32 bit version of the library
2) In the c++ code I replace the line #include fftw3.h by #include "fftw3.h". Apparently that was the big deal.
3) I executed the following command : mex -v tdelay_3D.cpp -llibfftw3-3 -L"Folder_where_libfftw3-3_is"

Community Treasure Hunt

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

Start Hunting!