LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a c++ dll,thank you!

HI,now I am using a CY7C68013A in my project,and now  I'm calling a dll function, when compile the programme,cvi returns many errors:
 
and could you tell me how to solve the problem!
 
thanks for your help!
 
  "CyAPI.h"(77,7)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(77,21)   syntax error; found '{' expecting ';'.
  "CyAPI.h"(78,7)   syntax error; found ':' expecting ';'.
  "CyAPI.h"(81,1)   Unrecognized declaration.
  "CyAPI.h"(104,7)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(105,1)   syntax error; found '{' expecting ';'.
  "CyAPI.h"(106,10)   syntax error; found ':' expecting ';'.
  "CyAPI.h"(107,8)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(109,11)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(110,11)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(113,7)   syntax error; found ':' expecting ';'.
  "CyAPI.h"(115,23)   Redeclaration of 'CCyUSBEndPoint' previously declared at CyAPI.h:104.
  "CyAPI.h"(116,32)   syntax error; found '&' expecting ')'.
  "CyAPI.h"(116,38)   Extraneous formal parameter specification.
  "CyAPI.h"(116,38)   Redeclaration of 'CCyUSBEndPoint' previously declared at CyAPI.h:115.
  "CyAPI.h"(117,70)   Redeclaration of 'CCyUSBEndPoint' previously declared at CyAPI.h:116.
  "CyAPI.h"(137,10)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(141,11)   syntax error; found 'identifier' expecting ';'.
  "CyAPI.h"(141,37)   syntax error; found '&' expecting ')'.
  "CyAPI.h"(141,69)   Missing parameter name to function 'XferData'.

帖子被www.cpubbs.com在09-21-2007 02:38 AM时编辑过了

--------------------------------------------------------------------------------------------
每一件事做了不一定成功,但不做就肯定失败,我会争取每一丝希望

http://www.cpubbs.com

cpu+bbs=cpubbs
0 Kudos
Message 1 of 7
(7,690 Views)
This pattern of errors is quite common when a typedef is missing. It is usually best to start with the very first error, so what is the actual text of line 77 in your file CyAPI.h? This should give a big clue as to what might be missing. It is likely that this header file assumes that other header files, which contains the missing typedef, (windows.h, for example) are also included in your project.
 
JR
0 Kudos
Message 2 of 7
(7,679 Views)
thank you for your help!
the content of line 77 is as following:
 
class CCyIsoPktInfo {
public:
 LONG Status;
 LONG Length;
};
 
and here  I upload the file in th attachment,thank you.

 

帖子被www.cpubbs.com在09-21-2007 09:21 PM时编辑过了

--------------------------------------------------------------------------------------------
每一件事做了不一定成功,但不做就肯定失败,我会争取每一丝希望

http://www.cpubbs.com

cpu+bbs=cpubbs
0 Kudos
Message 3 of 7
(7,660 Views)
Unfortunately this shows that your c++ dll is not compatible with CVI. CVI is an ANSI C89 compiler and as such does not recognise the class keyword (and quite a few others...) as this is a c++ language element. Your best bet is to go back to the supplier of the dll and see if they can provide a C version for you, which should be OK with CVI. (Another possibility, if you are desparate, is to produce your own C wrapper dll which contains the (translated) c++ functions - you could do this in a c++ environment such as Visual Studio. This can get tricky, if you are not familiar with the inner workings of c++ or the code you are translating.)
 
JR
0 Kudos
Message 4 of 7
(7,624 Views)
Hi,thank you for your help.I have used vc++ to call the dll functions,and coverted the functions to a style that cvi can call it;
 
thank your ,Mr JR.
 
cpubbs
--------------------------------------------------------------------------------------------
每一件事做了不一定成功,但不做就肯定失败,我会争取每一丝希望

http://www.cpubbs.com

cpu+bbs=cpubbs
0 Kudos
Message 5 of 7
(7,580 Views)
Hi,
 
I am not sure why you are getting all the errors.
 
Here is how I was able to get a program written in CVI version 8.0 to call functions in a dll written in Microsoft Visual Studio 2005.
 

//--C style Prototypes--//

#ifdef

_CVI_

int

__cdecl __export FUNCTION_NAME1(char *InitString);

int

__cdecl __export FUNCTION_NAME2(char *id);

//--C++ style Prototypes--//

#else

extern

"C" int __declspec(dllexport) FUNCTION_NAME1(char *InitString);

extern

"C" int __declspec(dllexport) FUNCTION_NAME2(char *id);

#endif

 

NOTE: The function must contain only datatypes that can be used in C.

For instance the function arguments cannot be class variables.

If this was your only issue your error would be something like: function X undefined.

-Garth

0 Kudos
Message 6 of 7
(7,549 Views)

这么大哥,没想到你两年前就开始尝试用CYAPI.lib封装成dll供labwindows调用了,小弟正在做这个,打算封装成供labview调用的dll,可惜在VC6.0环境下编译通过但link有错,不知道您有没这方面的经验,请传授小弟一二,不胜感激!!!!!!!!!!!!!!

0 Kudos
Message 7 of 7
(6,479 Views)