error LNK2019 occurs when running C Caller block in Simulink

3 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Juyeon Hong
Juyeon Hong am 2 Aug. 2019
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.

Weitere Antworten (1)

Chidvi Modala
Chidvi Modala am 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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by