LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compiling CIN on MVS C++

I have used CIN for 6 months for two different projects, following step by step the Labview manual and everything was fine.

Now for a third project, I have the followin linking errors :
cin.obj : error LNK2001: unresolved external symbol _CINRun
labview.lib(lvlvrt.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16
Debug/radio_labview.dll : fatal error LNK1120: 2 unresolved externals

They don't seem to be linked to the actual code in my CIN source file. Nevertheless, because of some library I use, my CIN source file is a ".cpp" instead of being a ".c". Can this trigger such errors ? If no, does some one has a cle of how to figure out what is going on.

Thanks a lot for your help
all the best
laurent
0 Kudos
Message 1 of 5
(3,290 Views)
Hi Laurent,

The VC++ compiler is name mangling them to C++ symbols, you will need to add an 'extern "C"' to those unresolved symbols.

Try doing this:

extern "C" {
#include "extcode.h"
}

and change your CINRun declaration to:

extern "C" CIN MgErr CINRun( use specific parameters );

If that doesn't work, you might want to make a copy of extcode.h to extcode.hpp and make the following changes:

On or around line 914 you should find a series of definitions such as
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);

These need to be changed to:

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);

The only remaining function is the CINRun function. In your main CIN file you will find a function definiton such as:

CIN MgErr CINRun( use specific parameters );

This should be changed to:

extern "C" CIN MgErr CINRun( use specific parameters );

NOTE - this is NOT the actual function definition line, but (usuall) the line above with the semi-colon at the end.

-Duffey
Message 2 of 5
(3,290 Views)
Hi Duffey,

Thanks a lot, this is working to solve my first error, the one with "_CINRun", but there is still the second one that doesn't come from extcode.h.

Here is the entiere error line :
labview.lib(lvlvrt.obj) : error LNK2001: unresolved external symbol __imp__MessageBoxA@16.

I am digging to find if I can use the extern"C" option wherever I link the labview.lib to my project. Is it the right approach ?

Your advice was very helpful, thanks again !!
Laurent
0 Kudos
Message 3 of 5
(3,290 Views)
Try doing it the second way I mentioned (rather than externing the entire header file).

Let me know if that does or does not work for you.

MessageBoxA is a windows function found in the windows's DLL.
0 Kudos
Message 4 of 5
(3,290 Views)
Hi,
sorry for taking so long to answer.

I tried both ways but that wasn't working.
I did some reserach about MessageBoxA, and I found a solution on NI website for tose kind of errors. I had to include a special compiling option and that worked.

Thanks a lot for you help, I really appreciate

LAurent
0 Kudos
Message 5 of 5
(3,290 Views)