MATLAB Answers

0

error LNK2019 occurs when running C Caller block in Simulink

Asked by Juyeon Hong on 5 Jul 2019
Latest activity Answered by Juyeon Hong on 2 Aug 2019
I made a very simple example of C Caller block to see how it works, but I got link error which I can't find out what the reason is.
in AudioDB.h
I created FuncTest() in C code.
Capture1.PNG
in AudioDB.cpp
Capture2.PNG
in Simulation Target menu of Configuration Parameters dialog,
I added like below
  • Header file : #include "AudioDB.h"
  • Source files : AudioDB.cpp
I put the .h, cpp files in the same directory with the model file, so I didnt add anything in the include directories item.
then I made parsing custom coded in model successfully, and tried to hook this function up with C Caller block.
Capture3.PNG
but when i start compiling/running the model, I got a link error regarding external interface like below, I have no idea what I should do to solve this error.
Capture4.PNG
Thank you.

  0 Comments

Sign in to comment.

2 Answers

Answer by Juyeon Hong on 2 Aug 2019
 Accepted Answer

I found the solution, I didnt change the language mode Matlab language into C language.
It works after I set the language as C.
Thank you.

  0 Comments

Sign in to comment.


Answer by Chidvi Modala on 30 Jul 2019

I am assuming that you included header file in the “Insert Custom Code in generated” section and
source code in the “Additional build information” section inside Configuration Parameters>>Simulation
Target.
From my understanding, you would like to use your source code inside Simulink. Include the source file and the header file as shown ‘AudioDB.cpp(including quotes) #include "AudioDB.h". I also assume that you know that the C Caller block integrates your externalCcode into Simulink. You can refer to this link to see if this helps

  0 Comments

Sign in to comment.