"loadlibrary" function gives error saying that size_t and MAX_SIZE are not defined.

3 views (last 30 days)
I have a shared C library that was built with MSVC 2017 on Windows 10. When I try to load the library using:
loadlibrary('myLibName', 'myHeaderName')
the compiler is throwing some errors saying that MAX_PATH and size_t are not defined. How can I resolve this issue and get loadlibrary to work?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Nov 2020
  1. MAX_PATH is a constant that is defined by Windows, and represents the maximum number of characters supported to represent a system path. Historically, this constant has been defined to be 260. This is defined in one of the general Windows header files, but to resolve the issue you can simply define MAX_PATH to 260 at the top of the file.
  2. size_t is a path that is defined in the stddef.h header file provided by Windows. To resolve this issue, you can include this header file at the top of your file.
It also should be noted that if you would like to use paths longer than 260 characters, you should be able to use _MAX_PATH as mentioned in the following Microsoft Documentation Page:

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!