LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a file in a CIN

I would like to read a file inside of a CIN. I am using Microsoft Visual C++ IDE.

To start off with, I compiled the mult.vi example included in the Using External Code manual. This successfully generates a mult.lsb file that can be imported.

From there I attempted to include fstream.h or iostream.h, both of which result in the error: "eh.h is only for C++!"

Come to find out, Microsoft Visual C++ determines whether the code is C, or C++, based on the extension.
(ref http://www.louisville.edu/~ecrouc01/CECS302/VisualCPP.htm)

I know that the file is .c, not .cpp, but in an attempt to get the file and console functions to work I:
- Delete mult.c from the project
- Change the file extension from mult.c to mult.cpp
- (Re)Import the new mult.cpp into the project
- Attempt a compile.

The result is:

--------------------Configuration: mult - Win32 Debug--------------------
Compiling...
mult.cpp
Linking...
Creating library mult___Win32_Debug/mult.lib and object mult___Win32_Debug/mult.exp
cin.obj : error LNK2001: unresolved external symbol _CINRun
mult___Win32_Debug/mult.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

mult.dll - 2 error(s), 0 warning(s)
----------------------------------------------------------------------------------------

So I tried to back out of this and found that a repeat of the above extension renaming process, back to the .c extension, does me no good. I get the above errors when compiling regardless.

I have no idea how to back out of what was changed, other than to delete the project and start over from scratch (not a small task considering all the options that have to be set).

I also have no idea how to use functions that would let me read a file or stream to the console (cin, cout, etc), not that I would expect to be able to do these necessarily, but I can't even include the .h file with compiler errors. All of the tutorials I have seen use these as the most basic functions, yet they won't run.

Any help or understanding of the above problems is appreciated.
0 Kudos
Message 1 of 3
(2,571 Views)
I'm not sure if it will help or not, but I have attached the detailed instructions I wrote up when wrestling with this last year.
I needed C++ in a DLL (not CIN), and detailed the steps to get there.

If CINRun is unresolved, you're not including the library in the library list.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 3
(2,570 Views)
Since the linker didn't know where CINRun should have been resolved from, and since all of the (supposedly) required libraries were loaded, it is impossible for me to even start to know where to look in this regard. However, after reading through your notes on DLL compilation I recalled seeing the note on extern "C" elsewhere in the LabVIEW documentation.

I have solved the problem by:
- Renaming the .c file to .cpp before importing it into Visual C++
- Using the extern "C" { stuffgoeshere } for both the function and function declaration.
- Adding the appropriate includes for file and console classes, which now give no errors

Thanks
0 Kudos
Message 3 of 3
(2,570 Views)