Jye S avatar image
Jye S asked Phil BoBo edited

Module Development - LNK 2019 Linking Error

I've been trying to access one of my custom modules from a secondary module. I figured it would be similar to using content from the ProcessFlow module, just needing the header file, so I copied the class header to the new module and added it to the solution. I was able to reference the class and its functions, however when building I got the error shown below: LNK2019: Unresolved external symbol.
After reading up online I worked out you need to include the .lib file for static linking or .dll for dynamic linking. Looking at the other FlexSim modules, the include only has the header files and the library file. So I tried to follow this, copying the same format as ProcessFlow.
I went into the project properties, added the library directory to point to the library file. I added the library file name to the additional dependencies.

This didn't seem to get me anywhere and I feel I'm missing something. I looked through the settings to see where it specified the path to the processflowcontent\ProcessFlow.lib and couldn't find it. The ProcessFlow library seems to connect just fine automatically using the module_template though.

I've attached a OneDrive link to the module here.


FlexSim 21.1.4
flexsim 21.1.4module sdkdllmodulesdll error
tempsnip.png (73.1 KiB)
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
Phil BoBo answered Phil BoBo edited

If you want to access a function or class in a library, you need to export that function or class when you compile that library and then import that function or class into the code where you are trying to access it.

See Exporting from a DLL Using __declspec(dllexport) | Microsoft Docs

See also the PROCESS_FLOW_EXPORT macro in the ProcessFlow headers. When we compile the ProcessFlow.dll, that macro evaluates to __declspec(dllexport), and when other modules use the headers, that macro evaluates to __declspec(dllimport) so that they can import the classes and functions that we exported.

5 |100000

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