LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of CINs to 64 bits DLL

Hi all,

 

Due to the use of some CINs in an old project, I need to update now the code with the use of DLLs. Moreover the conversion is also on the architecture, from 32 to 64 bits.

It seems to be a tricky challenge, has anyone tried this?

 

I achieve the conmpilation to 32 bits DLL but not in 64 bits. With Visual Studio 2013, I get the following link errors:

"error LNK2019: symbole externe non résolu DSNewHandle référencé dans la fonction Init

error LNK2019: symbole externe non résolu DSNewPClr référencé dans la fonction AllocPtr

error LNK2019: symbole externe non résolu DSDisposeHandle référencé dans la fonction Dispose

error LNK2019: symbole externe non résolu DSDisposePtr référencé dans la fonction FreePtr

error LNK2019: symbole externe non résolu MoveBlock référencé dans la fonction Demon_NewDatas

error LNK2019: symbole externe non résolu NumericArrayResize référencé dans la fonction Demon_GetParams

fatal error LNK1120: 6 externes non résolus"

 

All the functions mentionned is the error list, seem to be available in \Cintools\ labview.lib and \Shared\ lvrt.dll.

Under Visual Studio, I have specified the dependencies to a 32 bits or 64 bits LabVIEW Cintools directory and labview.lib but it fails to compile the 64 bits version.

Is the labview.lib compiled in 64 bits?

If not, how can I add the dependency to the lvrt.dll?

 

Thank you by advance for your help.

Regards

 

 

 

0 Kudos
Message 1 of 9
(3,111 Views)

These DSxxx functions are CIN functions, for 32 bit only.  Not compatible with 64 bit.

Same for any CIN lib, dll.

You just have to re-write the code.

 

 

George Zou
0 Kudos
Message 2 of 9
(3,092 Views)

Hi Zou,

 

Thank you for your reply.

I expected for a 64 bits LabVIEW version to have Cintools compiled in 64 bits, but it's not the case....

 

Rewrite the code means to know exactly what the functions do in low level layer.

Could we have acess somewhere to the code of the DSxxx functions?

0 Kudos
Message 3 of 9
(3,066 Views)

Since you're compile the dll, you can replace the input/output data type with ANSI C data type.

Then you don't need DSxxx function.  Simply use Windows API instead.

 

 

George Zou
0 Kudos
Message 4 of 9
(3,046 Views)

Actually, all those DSxxx functions are still there in the LabVIEW Runtime engine (lvrt.dll, the 64 bit version).

Not sure if they are still working, but you should be able to get your code to compile.

If you have problem with the header file and the .lib, you can always load the library dynamically.

 

 

George Zou
0 Kudos
Message 5 of 9
(3,036 Views)

Hi Zou,

 

Thank you for all your replies.

 

I would like to replace the DSNewHandle functions by malloc( ) but I am stuck.

I have seen that DSNewHandle return a char** (UHandle type ) whereas malloc returns a void*

 

How could I allocate a pointer of pointer on a structure?

 

Here is a part of the original code:

 

In header file:
typedef struct {
    int16 DemonNumChan;
    float32 DemonFEch;
    } Demon_Param_Struct,** DemonHandle;
    
In source file:

int Init(DemonHandle * pDemonParms)
{
    DemonHandle DemonParms;
    
    if (!(DemonParms = (DemonHandle) DSNewHandle(sizeof(Demon_Param_Struct))))
        return -1;

    (*DemonParms)->DemonNumChan = 4;
    (*DemonParms)->DemonFEch = 25600.0;
    
    *pDemonParms = DemonParms;
    
    return 0;
}

 

Thank you for your help.

0 Kudos
Message 6 of 9
(3,030 Views)

UHandle is a LabVIEW data type for string, array.

You need to switch to ANSI C data type.

 

I also have tons of CIN code waiting to convert to dll.

So I can use them in 64 bit code.

 

Good luck.

 

George Zou
0 Kudos
Message 7 of 9
(3,026 Views)

FSE-SAPHIR

As zou already noticed, you could not replace all LV functions to their WinAPI analogs but define LV functions, you need, dynamically in your DLL. Sample code to start is placed here: Creating a Shared Library (DLL) That Can Call LabVIEW Manager Functions (read after par. "Alternate Method"). So, in DllMain entry point (DLL_PROCESS_ATTACH case) you can simply link to needed functions by calling GetModuleHandle(NULL); or GetModuleHandle("lvrt.dll"); if you work in Run-Time Engine.

Another option is to export one additional function from your library:

extern "C" __declspec (dllexport) void SetLVRTModule(unsigned int module)
{
gLVRTmodule = module;
}

LabVIEW will call this function when loading the DLL, so you will have in gLVRTmodule base module address (labview.exe or lvrt.dll) and there is no need for GetModuleHandle. The next step is to determine some LV functions, that you are going to use, such as DSNewHandle. Look at the example with NumericArrayResize in the article I posted above.

0 Kudos
Message 8 of 9
(2,985 Views)

Hi dadreamer,

 

Thank you for your reply.

I will try this method during this week.

 

Regards

0 Kudos
Message 9 of 9
(2,965 Views)