question

Lucas Z avatar image
0 Likes"
Lucas Z asked Lucas Z edited

When can a DLL not be found? (When using Google Protobuffer)

In our model, we would like to communicatie with an external model where certain decisions are optimised. We call a DLL from Flexsim, this DLL calls then calls the external model and takes care of the rest.

Initial tests using the DLL were working well, except that we want to use Goolgle protobuffers to communicate from the DLL to the model, which includes some extra headers and a .cc file into the dll project. After including them, Flexsim cannot find the DLL anymore, everything else remaining the same. (exception: Dll Error : could not connect to exported dll function for /Tools/UserCommands/CallDll/code. Windows Error Code: 126)

When removing the additional files, Flexsim can find the DLL again. Currently we are not passing any parameters to the DLL function. What could be the cause for this to happen? Any help would be appreciated!


FlexSim 22.0.1
dlldll maker
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Phil BoBo avatar image
4 Likes"
Phil BoBo answered Phil BoBo edited

This isn't really a FlexSim question. This is a Google Protobuffers question.

Make sure you are using the appropriate platform (64-bit, not 32-bit) version of the libprotobuf library.

Make sure you are statically linking the protobuf library into your DLL. See "DLLs vs. static linking" section of protobuf/README.md at master · protocolbuffers/protobuf · GitHub

Based on what is happening, it sounds like you are dynamically linking the protobuf library, so when FlexSim tries to load your DLL, it then tries to load the dependency DLLs for that library (probably libprotobuf.dll or libprotoc.dll), and since it can't find them, it can't load your DLL.

Google Protobuffers is not just a simple C++ cc file and some header files. It's a large library of code that is required for those files to work. You need to actually embed all that code into your DLL for those generated C++ files to work.

See also:

The Bizarre Google World: Bazel, ProtoBuf, and More - It-Jim

[Dependencies] Never had so much difficulties to integrate a library (protobuf) in my life (C++ / Qt / Windows) (google.com)

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.