question

Stefan Haeussler avatar image
1 Like"
Stefan Haeussler asked Phil BoBo edited

Include c++ header files in Flexsim 7.7

Hi all,

I am trying to include a C++ header file in my flexsim 7.7.

I followed the instructions of the Forum: (https://www.flexsim.com/community/forum/showthread.php?t=3358): I created a node with string data within the Tools folder in the tree, right-clicked it and selected Build > Toggle Node as Global C++, then put

#include "../../../libraries/Lingd16.h"

within that node's data, but Flexsim keeps saying:

all.obj : error LNK2019: unresolved external symbol LScreateEnvLng referenced in function ObjectFunction376__project_model_Tools_UserCommands_command2_code

all.obj : error LNK2019: unresolved external symbol LSdeleteEnvLng referenced in function ObjectFunction376__project_model_Tools_UserCommands_command2_code

.\A\flexsimcontent.dll : fatal error LNK1120: 4 unresolved externals

When I build the solution in Visual Studio Express 2015 it says no errors - any ideas?

Yours,

Stefan

FlexSim 7.7.4
c++
5 |100000

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

Stefan Haeussler avatar image
3 Likes"
Stefan Haeussler answered Phil BoBo edited

Dear all,

I found a solution to my problem by creatng a DLL that attaches to FlexSim. Now I am calling the function specified in the dll through a User Command.

The manual really helped a lot: Creating DLLs that attach to FlexSim

Additionally, I added the .lib file of (Lingd64_16.lib) the additional dependencies in Visual Studio-Properties. (Properties - Configuration Properties - Linker - Input - Additional dependencies)

Thanks again for your help,

Greetings, Stefan

5 |100000

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

Phil BoBo avatar image
5 Likes"
Phil BoBo answered Stefan Haeussler edited

Additional Binaries

You can use the ModelLibraries functionality to specify additional lib or obj files that contain the compiled C++ code that is declared in the header file you are including.

From User Manual ModelLibraries Node:

binaries - You can add a node named "binaries" and give it text data that specifies a list of additional .lib or .obj files that you want to link to when FlexSim is compiled. This is only needed if you have c++ toggled code that must be compiled, or if you expect your end users to define c++ code that can access pre-compiled functionality. This text will be added to the "Additional Library Dependency" field during the C++ linker phase. The linker's library path is specified as /program/system/lib in FlexSim's install directory, so to link with a lib file in FlexSim's libraries directory, you would specify a path like: ../../../libraries/MyLib...

Using a DLL Instead

An easier way to include additional C++ library code would be to create a DLL that attached to FlexSim and includes the custom library you are trying to use. The link below explains how to create DLLs that attach to FlexSim.

Creating DLLs that attach to FlexSim

· 6
5 |100000

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