From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulink Model compilation attempt results in an EXE file instead of a DLL

Solved!
Go to solution

Hello all, 

 I've tried to compile a Simulink model for use with Veristand 2019 R3. I've done it before for NIVS 2018 (with Matlab 2016b) and it worked well. For 2019R3 though, there's a new *.tlc file introduced and Veristand Version Compatibility page says it needs a different compiler (MinGW instead of Windows SDK 7.1). 

 I've managed to get the compilation running using Matlab 2018a with Matlab-provided MinGW compiler... There's one problem, though - the result of the compilation is an EXE instead of a DLL. Any suggestions?

 Thank you in advance!

 

 Veristand: 2019 R3

 Matlab: 2018a (Simulink, Stateflow, MinGW compiler)

 

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 1 of 16
(5,736 Views)

Hello Jiri,

 Thank you! 

 That's essentially the same article that I linked in the initial post... I've read it again, however, and noticed that there is another table for PharLap compatibility (I've been looking at the Windows table all the time - sorry, should've read it more thoroughly). That table lists R2018a as incompatible anyway - I need at most R2017b (with Windows SDK 7.1) for PharLap support... (Time to move to Linux, I think).

 

 I've tried pointing Matlab to different compilers according to https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7qZSAS&l=pl-PL and here are the results:

- Veristand compiler for Linux 64-bit: compiles an *.so file - seems OK

- Veristand compiler for Linux 32-bit: compiles an *.so file - seems OK

- Veristand compiler for Windows: fails with following error

"Error(s) encountered while building "squibs": ### Failed to generate all binary outputs.

Caused by:
  • Validation error(s): ### Validating other build tools ... Unable to locate build tool "GCC Linker": g++ Unable to locate build tool "g++": g++ Unable to locate build tool "GCC Linker": g++ Located build tool "gcc": gcc Located build tool "GNU Archiver": ar"

 

I have "C/C++ Development Tools for NI Linux RT 2017" installed. Should it work for generating models for Windows too or do I need to install another compiler package for this?

This topic in Veristand Help: https://www.ni.com/documentation/en/veristand/latest/manual/select-compiler/ points out that for compiling models for Windows one needs an "environment variable", but doesn't specify its name nor the expected contents.

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 3 of 16
(5,700 Views)

Hi Piotr,

it was not clear to me from your post, that you want to generate model for Windows... I expected somehow Linux.

Honestly I haven't tried yet with R3...

~Jiri

CLA, CTA, CLED

0 Kudos
Message 4 of 16
(5,687 Views)

Hi Jiri,

 That's fine 🙂 I should've been more specific. I ran into this problem on Friday afternoon... 

 My goal is to have fully functional model compiling environment, as the only Veristand platform that we don't have around here is an VxWorks cRIO... 🙂

 

 In fact the problem started from an attempt to compile model for PharLap. Now I know that for this I need older Matlab and the Windows SDK 7.1 (seems like I can use the same toolchain as for NIVS2018).

 By the way - should older models (compiled for Veristand 2018) run without changes in 2019 or do they require recompiling because of changes in Model Framework?

 

 Then I tried to compile with another compiler, but I missed the entries for Veristand toolchains. Now it's clear that there are entries for Linux compilers and they require C/C++ Development tools for Linux RT.

 

 One thing that remains is to solve is to get the Windows-targeting compiler to run. NI Support people pointed me to another KB article: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000001DmQcCAK&l=pl-PL

If it's true, I need to check which MinGW compilers are installed on my machine (I expect two - Matlab-provided and Ni DevTools-provided) and properly manipulate system PATH, depending on which platform I'm building the model for.

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 5 of 16
(5,682 Views)
Solution
Accepted by topic author iwane

Hi Piotr,

I've got a hint from colleagues. 

 

  • The MATLAB provided mingw doesn't support building 32 bit dlls. Since the VS engine is 32-bit, we need a compiler that supports it. The official mingw project has several win32 toolchains that will do the job.
  • It seems that installing Eclipse will add those provided gcc.exe to your PATH Environment Variable. You will need to ensure that the default gcc in is the mingw provided one. This is in the linked KB...

Would you check?

 

Thanks,

 

Jiri

CLA, CTA, CLED

Message 6 of 16
(5,665 Views)

Hi Piotr,

 

Just to add on to Jiri's comments, you can find the mingw project here: https://sourceforge.net/projects/mingw-w64/files/. As our documentation states, VeriStand will require MinGW-w64 for 32-bit and 64-bit Windows with slsj and win32 options: https://www.ni.com/documentation/en/veristand/latest/manual/select-compiler/. The toolchain I would recommend is here: x86_64-win32-sjlj

 

Once you install the "correct" MinGW-w64, you can follow that KB you linked earlier. We'll make sure to update that KB to include the information on MinGW versions so this is clearer.

 

Best,

Brian

Brian.D
NI Product Owner
VeriStand
Message 7 of 16
(5,660 Views)

Hi Jiri & Brian,

 Thank you for pointers and the information. I'll have to download the MinGW compiler somehow (IT policy blocks us from SourceForge...) and test if it works - this can take some time...

 It seems like the solution will be to have BAT files to run Matlab with proper PATH setup based on the platform for which the model is targeted.

Piotr F.
Hardware Engineer @ ZF
0 Kudos
Message 8 of 16
(5,634 Views)
Solution
Accepted by topic author iwane

Hi Piotr,

 

You should not actually require having the Eclipse provided gcc.exe in PATH to compile models for NI Linux RT with the NI toolchain. I believe the Eclipse installation automatically adds those to PATH, but it should not be required. So, you should just need MinGW added to PATH after you install the compatible version.

 

Best,

Brian

Brian.D
NI Product Owner
VeriStand
0 Kudos
Message 9 of 16
(5,612 Views)

mimadiule_0-1582767626466.png

"Remove Eclipse added GCC from path and leave MinGW64 in the path" can work.  Veristand 2019 r3 model generation is still more complex than before. I've tried different combination of the TLC and compilers. Hope this is useful for others to reference.

Message 10 of 16
(5,591 Views)