Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > USB Controllers > CyAPI.lib link error with MATLAB

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



CyAPI.lib link error with MATLAB
Moderator:
RSKV

Post Reply
Follow this topic



CyAPI.lib link error with MATLAB

walkingcrane posted on 22 May 2012 6:24 AM PST
Member
4 Forum Posts

I am trying to use MATLAB to create a mexfunction (Matlab EXecutable) so that I can talk to a PSoC3 over USB to gather data.  I am using the following command:

>> mex openusb.cpp -lCyAPI

MATLAB uses Visual C++ Express as the compiler.  When I do this I get the following link errors:

   Creating library C:\USERS\JMILLI~1\APPDATA\LOCAL\TEMP\MEX_HI~1\templib.x and object C:\USERS\JMILLI~1\APPDATA\LOCAL\TEMP\MEX_HI~1\templib.exp
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
CyAPI.lib(CyAPI.obj) : error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList referenced in function "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ)
CyAPI.lib(CyAPI.obj) : error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInterfaces referenced in function "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ)
CyAPI.lib(CyAPI.obj) : error LNK2019: unresolved external symbol __imp_SetupDiGetClassDevsA referenced in function "public: unsigned char __cdecl CCyUSBDevice::DeviceCount(void)" (?DeviceCount@CCyUSBDevice@@QEAAEXZ)
CyAPI.lib(CyAPI.obj) : error LNK2019: unresolved external symbol __imp_SetupDiGetDeviceInterfaceDetailA referenced in function "public: bool __cdecl CCyUSBDevice::CreateHandle(unsigned char)" (?CreateHandle@CCyUSBDevice@@QEAA_NE@Z)
openusb.mexw64 : fatal error LNK1120: 4 unresolved externals

Anyone have any ideas?  Thanks.




Re: CyAPI.lib link error with MATLAB

aasi posted on 23 May 2012 01:55 AM PST
Cypress Employee
1090 Forum Posts

The calls (like SetupDiDestroyDeviceInfoList) being shown in the error message that you're getting are windows calls used in the library. Seems it is due to ignoring of default libraries by Visual C++ Express parser that you're using.

Please check if you've a way of enabling this. (The equivalent in VS environment would be Project --> Properties --> Linker --> Input --> Ignore All Default Libraries....

Regards,

Anand



Re: CyAPI.lib link error with MATLAB

aasi posted on 23 May 2012 01:56 AM PST
Cypress Employee
1090 Forum Posts

By the way we've not tested CyAPI.lib with MATLAB so I'm not much sure about how much compatible our library is with MATLAB.

Anand



Re: CyAPI.lib link error with MATLAB

walkingcrane posted on 23 May 2012 12:33 PM PST
Member
4 Forum Posts

Thanks I will try playing with the linker options for libraries.  I have also noticed that the *.map file is empty.  Is this because the linker fails, or is this what is causing the linker to fail?



Re: CyAPI.lib link error with MATLAB

walkingcrane posted on 23 May 2012 01:47 PM PST
Member
4 Forum Posts

Another question: What is the difference between CyAPI.lib and CyUSB.dll?  I think maybe there is a problem linking to the .dll file.



Re: CyAPI.lib link error with MATLAB

walkingcrane posted on 23 May 2012 07:04 PM PST
Member
4 Forum Posts

Hi Anand,

Can you tell me more about this:

http://www.cypress.com/?app=forum&id=167&rID=48607

Specifically, how do I know what methods are available and how do I use them?  Is there an app note or something?  Thanks.

-Jamie



Re: CyAPI.lib link error with MATLAB

PRJI posted on 24 May 2012 10:26 PM PST
Cypress Employee
333 Forum Posts

 Hi,

   CyAPI.lib is VC++ library whereas CyUSB.dll is VC# library. Following application notes show how to add cypress provided libraries (CyAPI.lib and CyUSB.dll ) to VC++ and VC# projects and how to develop simple host applications using library:http://www.cypress.com/?rID=12974 and http://www.cypress.com/?rID=43538. For more information on methods and its usage install SuiteUSB(http://www.cypress.com/?rID=34870), after installation you can see CyAPI and CyUSB.NET folders in C:\Cypress\Cypress Suite USB 3.4.7 ,these folders contain example projects and documentation on library(Cypress CyUSB .NET DLL Programmer's Reference and Cypress CyAPI Programmer's Reference).



Re: CyAPI.lib link error with MATLAB

Gayathri posted on 24 May 2012 10:34 PM PST
Cypress Employee
428 Forum Posts

 Hi,

 

CyUSB.dll is a managed Microsoft .NET class library. It provides  simpler and more powerful APIs. CyUSB.dll supports the  cyusb.sys, usbstor.sys, and usbhid.sys device drivers increasing the spectrum of devices that can be accessed with this tool. Cyusb.dll easily handles USB PNP events  too. Because cyusb.dll is a managed .NET library, its classes and methods  can be accessed from any of the Microsoft Visual Stuido.NET managed languages such as Visual Basic.NET, C#, Visual J#, and Managed C++.

 

CyAPI.lib is an unmanaged statically linked library. Because  CyAPI.lib is a statically linked C++ library, its classes and functions can be accessed from  C++ compilers  such as Microsoft Visual  C++.

 

Programer's reference guide for either of these can be found at Start -> Programs -> Cypress -> SuiteUSB -> help 

 ->Programmer's Reference for C# library (for CyUSB.dll)

-> Programer's Reference for  C++ library (for CyAPI.lib)

after installing Cypress SuiteUSB (http://www.cypress.com/?rID=34870).

 

In order to get started with the application development using these you may refer http://www.cypress.com/?rID=43538 (for CyAPI.lib) or http://www.cypress.com/?rID=12974 (for CyUSB.dll). These App notes are just a beginner's guide kind of document. That will point you to more practical examples using the particular library.

 

Regards,

Gayathri






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20