I want to use C external functions in Dymola. I try many examples in the book.
I got the error messages somethings look like this
Compiling the model with GCC.
October 19, 2006 11:22:09
gcc -c -O1 -mpentium -march=pentium -ffast-math -DDYMOSIM dsmodel.c
C:\Dymola5.0\source\dsblock1.c: In function `equations_':
C:\Dymola5.0\source\dsblock1.c:210: warning: This file contains more `{'s than `}'s.
C:\Dymola5.0\source\dsblock2.c: In function `dsblock_':
C:\Dymola5.0\source\dsblock2.c:98: warning: This file contains more `{'s than `}'s.
C:\Dymola5.0\source\dsblock3.c:57: warning: This file contains more `{'s than `}'s.
C:\Dymola5.0\source\dsblock4.c: In function `declare_':
C:\Dymola5.0\source\dsblock4.c:91: warning: This file contains more `}'s than `{'s.
C:\Dymola5.0\source\dsblock5.c: At top level:
C:\Dymola5.0\source\dsblock5.c:278: warning: This file contains more `}'s than `{'s.
Linking the model to Dymosim.
October 19, 2006 11:22:09
gcc -s -o dymosim.exe dymosim.o dsmodel.o -L. -lds -lm
dsmodel.o(.text+0xe73b):dsmodel.c: undefined reference to `Chrip'
Error generating Dymosim.
October 19, 2006 11:22:10
--------------------------------------------------------------------------------------------------------
Compiling and linking the model for DDE (Visual C++).
October 19, 2006 11:23:38
Setting environment for using Microsoft Visual C++ tools.
dsmodel.c
dsmodel.obj : error LNK2001: unresolved external symbol _Chrip
dymosim.exe : fatal error LNK1120: 1 unresolved externals
Error generating Dymosim.
October 19, 2006 11:23:38
This is my first time to use C external function. Does anyone help me to identify the errors? Please try to run my codes.
new_wave
I forgot another file for C code.
I don't know why I can not post a file wih .c extension. However, the code is simple.
Please include this in the file "Chirp.c"
#include <stdlib.h>
#include <string.h>
#include <math.h>
double Chirp(double w1, double w2, double A, double M, double time)
{
double res;
res=A*cos(w1*time+(w2-w1)*time*time/(2*M));
return res;
}
new_wave