LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with code interface node

I'm am experiencing problems to compile a Code
Interface Node using Microsoft Visual C++.

I followed the procedure described in the "Labview advanced I" manual
for the required settings. This procedure is also described in the web site.
I keep getting the following error message:

--------------------Configuration: MyFirstCIN - Win32 Debug--------------------
Compiling...
MyFirstCIN.c
Linking...
cin.obj : error LNK2001: unresolved external symbol _CINProperties
cin.obj : error LNK2001: unresolved external symbol _CINUnload
cin.obj : error LNK2001: unresolved external symbol _CINSave
cin.obj : error LNK2001: unresolved external symbol _CINLoad
cin.obj : error LNK2001: unresolved external symbol _CINAbort
cin.obj : error LNK2001: unresolved external symbol _CINDispose
cin.obj : error LNK2001: unresolved external symbol _CINInit
Debug/MyFirstCIN.dll : fatal error LNK1120: 7 unresolved externals
Error executing link.exe.

MyFirstCIN.dll - 8 error(s), 0 warning(s)


I tried a solution that is proposed in the FAQ site. This solution
is as follow:

1- Modify the following lines in the "extcode.h" file.:

CIN MgErr CINInit(void);
CIN MgErr CINDispose(void);
CIN MgErr CINAbort(void);
CIN MgErr CINLoad(RsrcFile reserved);
CIN MgErr CINUnload(void);
CIN MgErr CINSave(RsrcFile reserved);
CIN MgErr CINProperties(int32 selector, void *arg);

by:

extern "C" CIN MgErr CINInit(void);
extern "C" CIN MgErr CINDispose(void);
extern "C" CIN MgErr CINAbort(void);
extern "C" CIN MgErr CINLoad(RsrcFile reserved);
extern "C" CIN MgErr CINUnload(void);
extern "C" CIN MgErr CINSave(RsrcFile reserved);
extern "C" CIN MgErr CINProperties(int32 selector, void *arg);

2- Modify the following line in the .c file:

CIN MgErr CINRun(uInt8 *Input, uInt8 *Output);

by:

extern "C" CIN MgErr CINRun(uInt8 *Input, uInt8 *Output);


Doing this solution, I get the following error message when compiling:

--------------------Configuration: MyFirstCIN - Win32 Debug--------------------
Compiling...
MyFirstCIN.c
c:\program files\national instruments\labview\cintools\extcode.h(1084) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1085) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1086) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1087) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1088) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1089) : error C2059: syntax error : 'string'
c:\program files\national instruments\labview\cintools\extcode.h(1090) : error C2059: syntax error : 'string'
c:\@_projets\floadw vs labview\myfirstcin\myfirstcin.c(9) : error C2059: syntax error : 'string'
Error executing cl.exe.

MyFirstCIN.dll - 8 error(s), 0 warning(s)



What can I try next?
0 Kudos
Message 1 of 5
(3,871 Views)
Are you trying to compile this as a DLL?

A DLL is not compatible with a CIN. A DLL can be called with the DLL call in LabVIEW (found right next to the CIN call.)

I ask because in your message, the first compiler error list shows your filename as MyFirstCIN.dll. If you are trying to compile this code as a DLL, and have used these settings, then you will probably run into problems like this.
Message 2 of 5
(3,871 Views)
Hi Labviewguru,
thanks for answering so fast.

In the procedure that I use to try to build the CIN (actually
the .lsb file), it is specified to first create a new
"DLL" project in the Microsoft Visual C++ (version 6.0)
environment.

Is that procedure wrong? Should I first create another
type of project? Is there another procedure that I should follow
when using Microsoft Visual C++ 6.0?
0 Kudos
Message 3 of 5
(3,871 Views)

alaind,

I would suggest following the directions in the Using External Code in LabVIEW manual that ships with LabVIEW and is available on the web (go to ni.com and search for the manual name). This gives great directions on creating a CIN with Visual C++. I would also suggest a tutorial entitled How to build a CIN code resource (.lsb file). The only chnage to that information is to ignore the win32 directory in the path settings if you are using LabVIEW 6.0 or later.

Randy Hoskin
Applications Engineer
National Instruments

0 Kudos
Message 4 of 5
(3,871 Views)
Hi,

I wrote a few days ago about problems concerning the compilation
of code resource (.lsb files) for CINs. Someone from NI
suggested me to double check the procedure that I was using,
but this never helped. So I tried to compile on different
computers than my own, and it work fine on 2 PCs out of 3 that
I tried.

However, the compilation does not work anymore on one of the two,
after that I did a bad setting in the MSVC++ 6.0 DLL project.
This setting was as follow:

Project>> settings>> All config>> C/C++>> code generation
>> struct member alignment>> 8byte

instead of:

Project>> settings>> All config>> C/C++>> code generation
>> struct member alignment>> 1byte

I tried to create a new project with all the right settings.
but the computer keeps freezing during the build, when calling
the LVSB utility after the linking.
The next step is to uninstall and reinstall Labview 5.0 on this computer, but
it does not look too promising.

In the very first computer(my own) that I used, I uninstalled MSVC++ and
Labview 5.0, and reinstalled them afterwards, but the compilation
never worked.
I have finally been able to compile and get the code interface node
working on this computer after formating my hard drive and reinstalling
Windows 98, MSVC++ 6.0 and Labview 5.0. But for how long is it going to work fine?

So I have a strong feeling that the LVSB utility is not very stable,
and is doing damages to the settings of the computer whenever it crashes.
Is there a way to do the fix to the system without the need of reinstalling
everything? Do you have an idea about what is affected by the crash of
the LVSB utility? What is involved in the execution of this utility?

Here is my configuration:

MSVC++ 6.0

DLL empty project

Files added to the project:
cin.obj, labview.lib, lvsb.lib, lvsbmain.def, and the .c file

Project>> settings>> All config>> C/C++>> code generation>> Multithreaded DLL

Project>> settings>> All config>> C/C++>> code generation>> struct member alignment>> 1byte

Project>> settings>> All config>> C/C++>> preprocessor>> additionnal include directories>>
C:\Program Files\National Instruments\LabVIEW\CINTOOLS\

Project>> settings>> All config>> C/C++>> custom build>> commands>>
"C:\Program Files\National Instruments\LabVIEW\CINTOOLS\win32\lvsbutil" "$(TargetName)" -d "$(WkspDir)\$(OutDir)"

Project>> settings>> All config>> C/C++>> custom build>> outputs>>
$(OutDir)$(TargetName).lsb
Message 5 of 5
(3,870 Views)