LNK1181 :cannot open input file 'kernel32.lib'

10 vues (au cours des 30 derniers jours)
ThV
ThV le 24 Juil 2018
When I am using mex, I got the "famous" error LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
I checked on many forums, there is not a unique nor simple solution. However, in my case, it seems mex is not looking at the right place.
Here what I found from running mex -v nameFile.c (last lines of codes)
link /nologo /manifest /DLL /EXPORT:mexFunction C:\Users\UserName\AppData\Local\Temp\mex_8042614321131_11724\nameFile.obj /LIBPATH:"C:\Program Files\MATLAB\R2016a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:nameFile.mexw64
Error using mex LINK : fatal error LNK1181: cannot open input file 'kernel32.lib'
The problem seems to be that kernel32.lib (as well as other files e.g user32.lib) is indeed not included in the directory "C:\Program Files\MATLAB\R2016a\extern\lib\win64\microsoft". However, that location does contain some .lib files such as the first file named libmx.lib (I guess that is why I don't get an error for this file)
I have looked on my computer, all the requested files are located in "C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\lib64" (including kernel32.lib, user32.lib....) So there are indeed installed on my computer.
I am pretty sure it is just a matter of a wrong path somewhere, either in some config file or environment variable...I don't know.
Note : Matlab is building with 'Microsoft Windows SDK 7.1 (C)'
Thanks for your help.
Regards, Thib

Réponses (1)

Kogee Leung
Kogee Leung le 10 Mai 2022
I had this same problem in my R2020b setup. What I did was using Windows search, located the directory in Matlab that hosted the kernel32.lib file. On my system it was found in:
C:\Program Files\MATLAB\R2020b\sys\lcc64\lcc64\lib64
For my mexcuda command I appended:
-L"C:\Program Files\MATLAB\R2020b\sys\lcc64\lcc64\lib64"
which fixed my linking problems

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by