For Programmers: Free Programming Magazines  


Home > Archive > Matlab > October 2006 > RTW - Compiling Simulink with S-Functions using DLL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RTW - Compiling Simulink with S-Functions using DLL
Ludo Visser

2006-10-30, 7:42 pm

I am currently working with a Simulink model that uses two S-Function
blocks, a few displays and a XY-scope. The S-Functions are implemented
by a DLL-file written in C++, compiled using MS Visual C++ 6. I use
MATLAB 6.5.0.180913a Release 13.

S-Function #1, 'comread', reads data from the serial port, validates
the data and outputs valid data to three output ports.
S-Function #2, 'coordproc', uses the data from 'comread' and additional
data from a second input to calculate a set of coordinates that are
outputted to the XY-scope.

The DLL-file were developed seperately in their respective directories,
the resulting DLL-files were then copied to a new directory in which
the complete Simulink model, 'radartest', is stored.

The model 'radartest' works perfectly fine in simulation mode, but I
need to compile it to a Real-Time Windows Target using the RT-Workshop.

Compiling fails with the following error:
fatal error LNK1181: cannot open input file "comread.obj"

Copying this file from the 'comread'-directory to the
'radartest'-directory and recompiling results in a new error:
fatal error LNK1181: cannot open input file "coordproc.obj"

Copying this file to the 'radartest'-directory results in a huge list
of 'multiple defines'- and 'unresolved external symbols'-errors.

I searched the Mathworks-website and Google toroughly, but I could not
find anything that could help me. I'd like to have some hints in which
direction I need to look to solve this problem.

Regards,
Ludo Visser

Jan Houska

2006-10-31, 8:02 am

Hi Ludo,

you cannot use the already compiled objects and link them to the
Real-Time Windows Target executable. This is because they were compiled
for two very different environments - one is Windows and the other is
the Real-Time Windows Target kernel. This is similar to e.g. trying to
link Windows object files to a Linux executable - that wouldn't work
either. The only difference is that in this case both the environments
are able to run on the same machine at the same time.

Your only chance is to recompile your module from the source, using the
Real-Time Workshop build process. There will be some problems, though.
First, Real-Time Workshop doesn't compile C++ in MATLAB 6.5.0, this is
supported from some later version (I don't remember exactly which one it
is). Then, there are several restrictions on what you can use in your
code - the most important is probably the requirement not to use any
Win32 API calls.

Good Luck, Jan


Ludo Visser wrote:
> I am currently working with a Simulink model that uses two S-Function
> blocks, a few displays and a XY-scope. The S-Functions are implemented
> by a DLL-file written in C++, compiled using MS Visual C++ 6. I use
> MATLAB 6.5.0.180913a Release 13.
>
> S-Function #1, 'comread', reads data from the serial port, validates
> the data and outputs valid data to three output ports.
> S-Function #2, 'coordproc', uses the data from 'comread' and additional
> data from a second input to calculate a set of coordinates that are
> outputted to the XY-scope.
>
> The DLL-file were developed seperately in their respective directories,
> the resulting DLL-files were then copied to a new directory in which
> the complete Simulink model, 'radartest', is stored.
>
> The model 'radartest' works perfectly fine in simulation mode, but I
> need to compile it to a Real-Time Windows Target using the RT-Workshop.
>
> Compiling fails with the following error:
> fatal error LNK1181: cannot open input file "comread.obj"
>
> Copying this file from the 'comread'-directory to the
> 'radartest'-directory and recompiling results in a new error:
> fatal error LNK1181: cannot open input file "coordproc.obj"
>
> Copying this file to the 'radartest'-directory results in a huge list
> of 'multiple defines'- and 'unresolved external symbols'-errors.
>
> I searched the Mathworks-website and Google toroughly, but I could not
> find anything that could help me. I'd like to have some hints in which
> direction I need to look to solve this problem.
>
> Regards,
> Ludo Visser
>



--------------------------------------------------------------------
Jan Houska HUMUSOFT s.r.o.
houska@humusoft.com Pobrezni 20
http://www.humusoft.com 186 00 Praha 8
tel: ++ 420 284 011 730 Czech Republic
fax: ++ 420 284 011 740
--------------------------------------------------------------------
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com