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

FTDI lib in C MEX function

Asked by Daniel on 22 Nov 2012

Hello,

I'd like to use the FTDI driver library http://www.ftdichip.com/Drivers/D2XX.htm to communicate with my development board. I've written a test C++ code in VS2010 to test the functioning of the library, It works well, but if I try to use this lib within a C-MEX S-Function I got the following error: I'm using the same compiler in both case.

>> mex mult.cpp D:\MATLAB\Projects\MATLABQUESTION\ftd2xx.lib
   Creating library C:\Users\Daniel\AppData\Local\Temp\mex_TYSDRk\templib.x and object C:\Users\Daniel\AppData\Local\Temp\mex_TYSDRk\templib.exp 
mult.obj : error LNK2019: unresolved external symbol __imp_FT_ListDevices referenced in function "void __cdecl mdlInitializeSizes(struct SimStruct_tag *)" (?mdlInitializeSizes@@YAXPEAUSimStruct_tag@@@Z) 
mult.mexw64 : fatal error LNK1120: 1 unresolved externals 

I uploaded the whole source: https://docs.google.com/folder/d/0B-6z-TDawep9MXFpb05pSXJkMDg/edit

Thank you,

Daniel

0 Comments

Daniel

Products

No products are associated with this question.

3 Answers

Answer by Daniel on 23 Nov 2012
Accepted answer

I found the problem, the library is an 32 bit lib.

0 Comments

Daniel
Answer by Daniel on 22 Nov 2012

I also tried to add the lib into the path, use #pragma comment(lib,"D:/MATLAB/Projects/CONFL/ftd2xx"); or declare the function like: FT_STATUS __cdecl FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD Flags);

What am I doing wrong? You can find the lib, header and the source under the given link.

Regards,

Daniel

0 Comments

Daniel
Answer by Hurter on 28 Jan 2013

Hi Daniel.

Have you succeeded in this. I want to do the exact same thing with the same DLL to get FTDI USB link to Matlab going.

I have succeed in implementing the ftdi dll to my Boland C builder but could not replicated it in Matlab.

I have also tried to use Matlab implib functions but struggle there to declare a #typedef variable that I need to call the functions like FT_List or FT_open.

Any why I think this is the way to go. If you succeed with this you can call the funtions needed straight from Matlab.

You can looks Walter Roberts answer that he gave me. Although I did not succeed yet. http://www.mathworks.com/matlabcentral/answers/59617-external-application-video-link-to-matlab

0 Comments

Hurter

Contact us