Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
linking problems when compiling c++ s-function

Subject: linking problems when compiling c++ s-function

From: Camilla

Date: 11 Jul, 2013 00:04:08

Message: 1 of 2

Hello everybody,
I am trying to create a c++ s-function. I have sensors that work perfectly in Visual Studio, but I would like to import them in Simulink.
So I adjusted the c++ code in a way that is compatible with the S-function template, but I have problems when I try to compile the file in Matlab.
In the command window I wrote :

mex imu_simulink.cpp ThreeSpace_API.lib

The error that results is the following: "
Creating library C:\Users\Seven\AppData\Local\Temp\mex_STIHED\templib.x and object C:\Users\Seven\AppData\Local\Temp\mex_STIHED\templib.exp

imu_simulink.obj : error LNK2019: unresolved external symbol tss_startStreaming referenced in function "public: void __cdecl TSSController::StartCollectingData(void)" (?StartCollectingData@TSSController@@QEAAXXZ)

 tss_startStreaming is a function that is defined in the .lib file

The file.lib is in the same folder of the file.cpp, and I have tried to use the -l option of mex :
mex imu_simulink.cpp -lThreeSpace_API

but the problem is still there!

How can I solve this linking problem?
Thanks in advance
Camilla

Subject: linking problems when compiling c++ s-function

From: Navan Ruthramoorthy

Date: 11 Jul, 2013 13:26:23

Message: 2 of 2

Hi Camilla,

Can you build a simple c++ function (not s-function) which calls your library function and see whether that builds properly without the same linker error? It could be a one liner inside a main function. This will confirm whether the function is correctly exported from the library.

Using "-l" option is the correct way to link libraries.

Navan

"Camilla " <camilla.pierella@gmail.com> wrote in message <krkspo$rki$1@newscl01ah.mathworks.com>...
> Hello everybody,
> I am trying to create a c++ s-function. I have sensors that work perfectly in Visual Studio, but I would like to import them in Simulink.
> So I adjusted the c++ code in a way that is compatible with the S-function template, but I have problems when I try to compile the file in Matlab.
> In the command window I wrote :
>
> mex imu_simulink.cpp ThreeSpace_API.lib
>
> The error that results is the following: "
> Creating library C:\Users\Seven\AppData\Local\Temp\mex_STIHED\templib.x and object C:\Users\Seven\AppData\Local\Temp\mex_STIHED\templib.exp
>
> imu_simulink.obj : error LNK2019: unresolved external symbol tss_startStreaming referenced in function "public: void __cdecl TSSController::StartCollectingData(void)" (?StartCollectingData@TSSController@@QEAAXXZ)
>
> tss_startStreaming is a function that is defined in the .lib file
>
> The file.lib is in the same folder of the file.cpp, and I have tried to use the -l option of mex :
> mex imu_simulink.cpp -lThreeSpace_API
>
> but the problem is still there!
>
> How can I solve this linking problem?
> Thanks in advance
> Camilla

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us