Hi,
I edited the environment variables via Control Panel before Matlab was
running. In Matlab command window I typed getenv('path') and I see the bin
folder to the protobuf DLL which I have added.
I tried now four things:
- Add protobuf DLL path to the beginning of system path variable, not
the user path variable.
- Add protobuf DLL path as a LIB_PATH in S-function builder.
- Add system path variable directly as an ENV_PATH in S-function builder.
- Copy the DLL next to the model in the same folder.
None of them have been worked for me, I get the same error (Error while
obtaining sizes from mex s-function).
When I run the simulation, I also see an "Invalid mex file, the specified
module not found" error (not a DLL not found error, which I wrote earlier).
I do not know what I am doing wrong. Michael Ngarimu how could you make my
model work? What was your settings to provide the DLL to Matlab?
Regards,
Adam
Michael Ngarimu a következőt írta (2025. február 2., vasárnap, 3:00:10
UTC+1):
> [Since this is off-topic, I'm happy to take this off-list of mods deem it
> necessary].
>
> While, "yes" adding the directory containing the DLL to the PATH env var
> is one way the Windows dynamic loading can find a DLL.
> Dynamic-link library search order - Win32 apps | Microsoft Learn
> <https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps>
>
> I feel like you might not be aware of - or not considering - how
> environments in processes work. There is the question of how you updated
> the PATH variable, i.e., it depends on the process where you updated the
> environment (e.g., an existing instance of Powershell, the login instance
> of explorer.exe, or somewhere else) and whether or not Matlab was running
> and restarted.
>
> Although you've updated the PATH, could it have been while Matlab was
> running and has not been restarted? Or, you may have updated the PATH in a
> running cmd.exe shell with a simple PATH=..., or in a running Powershell
> instance with $env:PATH=... Starting a new copy of Matlab from the Start
> Menu where the explorer.exe is unaware of the change made will inherit an
> environment from explorer.exe that does not contain your change. Maybe the
> PATH was updated through Control Panel or Settings.app but Matlab was
> running at the time and has its own copy of the environment.
>
> Environment Variables - Win32 apps | Microsoft Learn
> <https://learn.microsoft.com/en-us/windows/win32/procthread/environment-variables>
>
> User Environment Variables - Win32 apps | Microsoft Learn
> <https://learn.microsoft.com/en-us/windows/win32/shell/user-environment-variables>
>
>
>
> On Saturday, February 1, 2025 at 1:31:02 AM UTC-8 Ádám Boronyák wrote:
>
>> Hi,
>>
>> Thanks for your explanations. I only add the path to the protobuf dll to
>> the PATH environment variable. I read that it should be enough for Matlab
>> to find the dll.
>> Michael Ngarimu what do you mean by "correctly provide the protobuf DLL
>> to Matlab"? How did you do it?
>>
>> Regards,
>> Adam
>>
>> Michael Ngarimu a következőt írta (2025. február 1., szombat, 3:40:40
>> UTC+1):
>>
>>> This does not look like a protobuf issue to me. Is it possible this is
>>> simply an issue that you haven't told Matlab how to find the protobuf DLL?
>>>
>>> Where is the "could not find dll like" issue?
>>>
>>> Beyond the scope of this list, I have ,
>>> 1. used vcpkg to acquire protobuf 3.21.12,
>>> 2. taken your model and modified the LIB_PATH and INC_PATH to point to
>>> location where vcpkg installed the protobuf headers and built libs,
>>> 3. rebuilt your s-function
>>>
>>> The only issue I ran into is Matlab S-Function builder gave a vague
>>> error that it could not obtain sizes from the MEX file....
>>>
>>> but that was because the MEX failed to build completely...
>>>
>>> but that was because Matlab doesn't know where to find the protobuf DLL.
>>>
>>> How are you making the protobuf DLL available to Matlab?
>>>
>>> When I correctly provide the protobuf DLL to Matlab, I can see the value
>>> you assign and retrieve through the protobuf::Timestamp (the value, 2) in
>>> the outputs from your model.
>>> [image: Screenshot 2025-01-31 183750.png]
>>>
>>> On Friday, January 31, 2025 at 1:14:14 AM UTC-8 Ádám Boronyák wrote:
>>>
>>>> Hi,
>>>>
>>>> I would like to integrate and use protobuf C++ library in Simulink
>>>> S-functions on Windows 10. For this purpose I have installed protobuf
>>>> 3.21.12 using Visual Studio 2022 via vcpkg. I have created a simple
>>>> Simulink model (attached to the email) with an S-function builder. In this
>>>> S-function builder I set a library path to vcpkg lib folder and an include
>>>> path to vcpkg include folder to be able to find protobuf headers and
>>>> libraries. I set there also the libprotobuf.lib as an entry. In
>>>> environment
>>>> variables I set path to the vcpkg bin folder because libprotobuf.lib links
>>>> to the corresponding dll file. So every link and entry have been set for
>>>> the project.
>>>> In my S-function in wrapper.cpp file (attached to the email), I create
>>>> an instance of the built-in Timestamp message, set the seconds field to 2
>>>> and give it to the output of the S-function. After I compile the
>>>> S-function
>>>> or try to run the Simulink model, Simulink freezes and after some time I
>>>> get a "could not find a dll" like issue which does not help to debug the
>>>> issue.
>>>> I created a contact with Mathworks and they suggested a way to debug
>>>> this. So I opened Visual Studio, opened the wrapper file, set a break
>>>> point
>>>> to the instance creation and attached the Matlab process to it. After I
>>>> try
>>>> to run my Simulink model I get an access violation exception. I have
>>>> attached a screenshot about it.
>>>> Mathworks suggested that I should contact you to help troubleshooting
>>>> this issue. What is your opinion about it? What can cause this issue?
>>>>
>>>> Regards,
>>>> Adam
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/protobuf/bf07de72-77f6-4e4d-a63d-d98576db407fn%40googlegroups.com.