LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

help needed using NiReport in MSVC (using C, not C++/MeasStudio)

Hi, folks!

 

I develop my apps writing in C, using MSVC (not Measurement Studio/C++). I use LabWindows to design the UI and use the external compiler support to generate the UI's object file, which I link into my program. I've had great results doing this; I link to the appropriate .lib and the corresponding .dll is in the apps root folder.

 

However, I'm unable to get this to work for using the NiReport library. I'm trying to build the nirsample app which came with my LabWindows installation but the link step fails because it cannot find the exported functions required (NI_Report_xxx).

 

There is a utility that comes with the MSVC installation called Depends, which allows one to view the imported and exported fuinctions in a .dll file. When I load up the NiReports.dll, it only exports four functions: DllCanUnloadNow, DllGetClassObject, DllRegisterServer and DllUnregisterServer. Where are all the NI_Report_xxx functions? I think if I can find the proper .dll, I'll be successful in building my app and will be able to go on with my life... 

 

Thanks in advance for any help.

 

[update]

I'm almost there! I'm using nirsample.c and nireport.obj in my test compile and it returns a link error saying it it has an unresolved external symbol, _StrDup@4. Ok, I know that StrDup is a function found in the CVI_Toolbox and I've included that in the libraries used to link against. I had a similar problem using the Excel automation functions and was able to get around it by including the source file, excel2000.c. So, if I could just get hold of the source for nireport.obj, I think that would solve my problem. However, unlike most of the other toolbox extras, this one does not include its source.

[/update ]

 

'til next we type...

HAVE FUN!! -- Jesse 

0 Kudos
Message 1 of 4
(3,339 Views)

Hi Jesse,

 

You'll need to make the following changes to your project:

 

  • Add the following dirs to your C/C++>>General>>Additional Include Directories
             C:\Program Files\National Instruments\CVI2009\include
             C:\Program Files\National Instruments\CVI2009\toolslib\toolbox

  • Add the following dir to the Linker>>General>>Additional Library Dependencies
             C:\program files\national instruments\cvi2009\extlib\msvc

  • Add the following libs to the Linker>>Input>>Additional Dependencies
             cvirt.lib cvisupp.lib cviauto.lib

  • Add toolbox .c to your source files.

Cheers,
Message Edited by Michael_W. on 03-11-2010 06:08 PM
0 Kudos
Message 2 of 4
(3,313 Views)

Michael,

 

Thanks for the quick response. A long time ago I rebuilt Toolbox as a dll; it works fine that way for all my other projects until this one. However, I tried your suggestion and it led to another error:

 

--------------------Configuration: NirSample - Win32 Debug--------------------

Compiling...

toolbox.c

c:\program files\microsoft visual studio\vc98\include\windef.h(252) : error C2371: 'HINSTANCE' : redefinition; different basic types

        g:\extlib\include\cvidef.h(144) : see declaration of 'HINSTANCE'

Error executing cl.exe.

 

NirSample.exe - 1 error(s), 0 warning(s)

 

My guess is this is because of a conflict in how the various include files are being loaded and I'm not sure how to fix that. (I do not have that problem when using toolbox as a dll for my other projects.)

 

For the sake of completeness, I've attached the MSVC project file (nirsample.dsp) so you can see how I've got this set up.  Oh, and I'm using MSVC 6.0 for coding and LabWindows 6.0 for ui design. (I don't have a CVI2009 directory.)

 

Jesse

 

p.s.: Your website won't let me upload the dsp file (the file extension is not valid), so I've renamed it NirSample.txt 

0 Kudos
Message 3 of 4
(3,296 Views)

Hi Jesse,

 

It appears windef.h doesn't have a macro to protect redef of HINSTANCE.  So if you make use of it, make sure you declare it before all other header files as they have redef protection.

 

Cheers, 

0 Kudos
Message 4 of 4
(3,284 Views)