LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

unresolver link dll cvi C

Hi,

I use CVI8.0. I want to have a dialogue with a microcontroleur 8 bits Silabs via the USB. I use a dll: SiUSBXp.dll, SIUSBXp.lib and SiUSBXp.h defined in packages USBexpress 3.1.
I added windows.h in the main transfert.c.



In my project, I added SIUSBXp.lib and SiUSBXp.h to the project nevertheless I obtien this error message:
 
7 Project link errors
  Undefined symbol '_SI_GetProductString@12' referenced in "transfert.c".
  Undefined symbol '_SI_Open@8' referenced in "transfert.c".
  Undefined symbol '_SI_Close@4' referenced in "transfert.c".
  Undefined symbol '_SI_Read@20' referenced in "transfert.c".
  Undefined symbol '_SI_SetTimeouts@8' referenced in "transfert.c".
  Undefined symbol '_SI_CheckRXQueue@12' referenced in "transfert.c".
  Undefined symbol '_SI_GetNumDevices@4' referenced in "transfert.c".
One error for each used function

Have to I clarify during the build that I use a DLL somewhere in CVI environnement ?

0 Kudos
Message 1 of 9
(4,630 Views)
including the lib and the header in the project should be enough.

i suspect a calling convention issue: isn't there anything specified concerning stdcall or cdecl in a help file for your library ?
from the message, the linker is looking for a __cdecl function ("_name@size"). try declaring all function as __stdcall in the library header (like "int __stdcall name()" )
0 Kudos
Message 2 of 9
(4,601 Views)
Hi

Not such enough!
You have to include in the source file the header file!
You have a linked problem..in the compilation the functions are not recognized.

Kamal
NIF
0 Kudos
Message 3 of 9
(4,579 Views)
Hi,

I want to use a USB connection  with a µP 8 bits. Making it gives me an USBEXPRESS module (*.lib,*.h,*.dll (written in C)).

I have includes " windows.h " in my main as well as the *.lib. and I have somme linkage error.

If I use directly in the header, the  agreement __ stdcall before yhe name of function, I have an error of linkage.

 If I use __ cdecl, no error but a bad functioning when I want to read or writeof the data in my µP.

schartzy
0 Kudos
Message 4 of 9
(4,571 Views)
ok, let's clear things up, to use the usbexpress library, you have to:
- add the .lib and .h to your project
- #include the .h from your main source file (not only windows.h !)
- DO NOT #include a .lib ! this does not mean anything !
- copy the .dll to the directory where your application is compiled.

from what i gathered on the internet, USBExpress calling convention is __stdcall (if every function name in the header is preceded by WINAPI, lookup the definition for WINAPI: it should be a #define for __stdcall !)

is everything correct on your side ? now compile, run and report any error you find.
0 Kudos
Message 5 of 9
(4,563 Views)
Hi,

I have already made all these things.... It has been 10 days since I am blocked...

NI support says to me that it is necessary to use __ cdecl but it is translated by a bad functioning...

I join you the coimpressed project (transfert.zip)  with the answers to printf used in comment.

there are in the archive, two SiUSBXp.h : one for __cdecl version and one __stdcall version (SiUSBXp_stdcall_ver.h). I change the name of this header when I want __cdecl or __stdcall.
Schartzy
0 Kudos
Message 6 of 9
(4,551 Views)

Public dlls should use __stdcall linkage, which you can also define as either WINAPI or APIENTRY, as in your SiUSBXp_stdcaal_ver.h header file. Is this how the original file looked? In my CVI7.0, I find I have to modify third party headers to remove the __declspec(dllimport) statement, as follows:

// Standard part of third party header, suitable for MSVC applications:

    #ifdef SI_USB_XP_EXPORTS
    #define SI_USB_XP_API __declspec(dllexport)
    #else
    #define SI_USB_XP_API __declspec(dllimport)
    #endif

// For CVI use, modified to:

    #ifdef SI_USB_XP_EXPORTS
    #define SI_USB_XP_API __declspec(dllexport)
    #else
    #define SI_USB_XP_API
    #endif


I have to confess I have not spent too much time investigating this: I found that it worked for me in the past when I had a problem so I always use it now. Worth a try.

JR

0 Kudos
Message 7 of 9
(4,544 Views)
thanks for the code. the problem is really a calling convention problem, and specifically, a name decoration problem when using a different calling convention.

i passed the lib through dumpbin (which is included with cvi and is a great tool to diagnose this kind of problems).

the linker is looking for "_SI_GetNumDevices@4" but the library defines "_SI_GetNumDevices". for this you have 2 solutions:
- or there is an option i don't know in cvi to specify the name decoration to use
- or you can regenerate the import lib from the dll, which may require writing a .def file to 'link' together the decorated name of the fundtion and the  dll name of the function (which is not decorated at all).

for the first case, we need someone at NI to reply. for the second case, i could help but i don't have the time nor the tool (implib or such) right now.

btw: from my recollection, there is no need for the size part (@4 for example) when using stdcall, and thus cvi should not generate such decorations. i may be wrong, can someone confirm this ?
0 Kudos
Message 8 of 9
(4,531 Views)
Hi,

I re-create a new import lib with cvi and it's work......Smiley Very Happy

Thanks for all
0 Kudos
Message 9 of 9
(4,516 Views)