LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hot to create a CVI 2010 project with visual studio 2010

Hello.

 

Is there someone that can explain step-by-step what I have to do to create a CVI 2010 project (including cvirt.lib, cvisupp.lib from the CVI2010/extlib folder and some tools) in Visual Studio 2010? As I found out so far, the creation and conversion wizards won't work with this version of Visual Studio (I also tried to just copy and past them from the Visual Studio 2008 project templates folder... but no success). I also followed the steps described in various LabWindows/CVI manual pages on ni.com (for example: LabWindows CVI 2010 Help).

 

The main problem is that I get a lot of linking errors stating that there are already defined symbols in MSVCRTD.lib.

 

While writing this I found out that the include library that one has to ignore is in fact libcmt.lib because libc.lib is no longer used in Visual Studio 2010, which now always uses a multi threaded version of libc.

 

Nevertheless I get other linking errors relating to toolbox.obj, msxmldom.obj, and cvixml.obj, and an unresolved function snprintf.

 

Here's the output (sorry, but I have only the german version of visual studio).

 

 

Fehler	1	error LNK2001: Nicht aufgelöstes externes Symbol "__mul64".	toolbox.obj
Fehler 2 error LNK2001: Nicht aufgelöstes externes Symbol "__ror64". toolbox.obj
Fehler 3 error LNK2001: Nicht aufgelöstes externes Symbol "__rol64". toolbox.obj
Fehler 4 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_InitActiveXThreadStyleForCurrentThread@8". toolbox.obj
Fehler 5 error LNK2001: Nicht aufgelöstes externes Symbol "__GetErrno". toolbox.obj
Fehler 6 error LNK2001: Nicht aufgelöstes externes Symbol "__GetFilesArray". toolbox.obj
BEGIN_EDIT:
Fehler 7 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantSetEmpty@4". msxmldom.obj
Fehler 8 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantSetEmpty@4". cvixml.obj
Fehler 9 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantClear@4". msxmldom.obj
Fehler 10 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantClear@4". cvixml.obj
Fehler 11 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_FreeMemory@4". msxmldom.obj
Fehler 12 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_FreeMemory@4". cvixml.obj
Fehler 13 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_FreeBSTR@4". msxmldom.obj
Fehler 14 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetInterfaceFromObjHandle@20". msxmldom.obj
Fehler 15 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_FillErrorInfoEx@20". msxmldom.obj
Fehler 16 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_CStringToBSTR@8". msxmldom.obj
Fehler 17 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_BSTRGetCString@8". msxmldom.obj
Fehler 18 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetLocale@8". msxmldom.obj
Fehler 19 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetSupportForMultithreading@8". msxmldom.obj
Fehler 20 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetActiveObjectByClassIdEx@28". msxmldom.obj
Fehler 21 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_CreateObjectByClassIdEx@28". msxmldom.obj
Fehler 22 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_LoadObjectFromFileByClassIdEx@32". msxmldom.obj
Fehler 23 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_CreateObjHandleFromInterface@28". msxmldom.obj
Fehler 24 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_DiscardObjHandle@4". msxmldom.obj
Fehler 25 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_DiscardObjHandle@4". cvixml.obj
Fehler 26 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_RegisterEventCallback@28". msxmldom.obj
Fehler 27 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetEventCallback@20". msxmldom.obj
Fehler 28 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantNULL@0". cvixml.obj
Fehler 29 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantSetObjHandle@12". cvixml.obj
Fehler 30 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantSetCString@8". cvixml.obj
Fehler 31 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_VariantConvertToType@12". cvixml.obj
Fehler 32 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_GetAutomationErrorString@12". cvixml.obj
Fehler 33 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_FillErrorInfo@12". cvixml.obj
Fehler 34 error LNK2001: Nicht aufgelöstes externes Symbol "_CA_DuplicateObjHandle@12". cvixml.obj

END_EDIT
Fehler 35 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_snprintf" in Funktion "_initialize". Analysis_DLL.obj
Fehler 36 error LNK2001: Nicht aufgelöstes externes Symbol "_snprintf". Importer.obj
Fehler 37 error LNK1120: 31 nicht aufgelöste externe Verweise.

 

Thank you for any help in advance.

 

Best regards

 

Hagen

 

 

EDIT: I found another missing lib file cviauto.lib so all the _CA_[...] error entries are gone. So there are only 6 errors left.

0 Kudos
Message 1 of 7
(5,338 Views)

I don't know anything on Visual Studio, but toolbox.obj can be found in <cvifolder>\toolslib\toolbox\msvc folder



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 7
(5,332 Views)

So after reading a bit more on the missing symbols, I found a thread in the NI forum where I found a solution to all of my problems.

 

Here's the link: unresolved external symbol GetErrno and GetFilesArray.

 

There LuisG wrote in his first response what has to be done to avoid (or better find) the missing symbols.

 

So here are the steps to create a CVI 2010 runtime project with Visual Studio 2010 (from LabWindows/CVI 2010 Help😞

 

  1. Create a new project in the external compiler. Include in the external compiler project any source (.c, .lib, and .obj (be careful with these; se below for details)) files that the LabWindows/CVI project includes.
  2. In the external compiler project settings, specify the CVIversion\include directory as an include path for the LabWindows/CVI library include files.
  3. If the LabWindows/CVI project includes one or more instrument drivers, add the program files that correspond to those instrument driver files to the external compiler project. Select Instrument»Edit and then click Show Info to display the program file location.
    Also add any program files on which the listed instrument driver depends. Select Edit».FP Auto-Load List to access a list of other instrument drivers on which the current instrument driver depends.
  4. Add the following files from CVIversion\extlib\msvc or CVIversion\extlib\msvc64 to the external compiler project:
    • cvirt.lib
    • cvisupp.lib
    These libraries include the LabWindows/CVI startup library and an import library that contains the User Interface Library, Formatting and I/O Library, RS-232 Library, DDE Support Library, TCP Support Library, Utility Library, UDP Support Library, and the Real-Time Utility Library.

    Note Note  The Real-Time Utility Library is available when you install the LabWindows/CVI Real-Time Module. For more information about this library, refer to the LabWindows/CVI Real-Time Module Help»Real-Time Utility Library section of this help file.

    The msvc and msvc64 folders in the following directories contain additional files you can add to the external compiler project, depending on the LabWindows/CVI libraries you use in the project.

    • CVIversion\extlib
    • National Instruments\Shared\CVI\Extlib
    • Windows 7/Vista/Server 2008: ProgramData\National Instruments\CVIversion\extlib
    • Windows XP/Server 2003: Documents and Settings\All Users\Application Data\National Instruments\CVIversion\extlib
    Note Note  Import library files for National Instruments hardware libraries might be located in CVIversion\extlib and not within the msvc or msvc64 folders.
  5. Complete this step only if you are building your project in Microsoft Visual Studio 2005 or Microsoft Visual Studio 2008. Visual Studio 2005 and later does not include support for the single-threaded version of the Visual Studio C library. Therefore, you must configure your project's linker settings to ignore directives to use the single-threaded C library. In Visual Studio, select Project»Properties and expand the properties tree to the Configuration Properties»Linker»Input item. Add libc to the Ignore Specific Library option.
    Visual Studio 2010 (or more precisely MSVC 10.0) does not use the single-threaded C library anymore, it always uses a multi-threaded version named libcmt.lib. So you have to add libcmt.lib to the Ignore Specific Library linker option.
  6. If the LabWindows/CVI project includes .uir files that have callbacks, use the External Compiler Support dialog box to create a .c or .obj file that contains a table of callback functions and function names. Add the generated source or object file to the external compiler project.
  7. To use toolbox functions of CVI you should NOT include the corresponding obj files from the CVIversion\toolslib\toolbox folder. Instead you should include the sources (.c files) of the corresponding tools you need (as stated in the above mentioned post; thanks to LuisG) and add the CVIversion\toolslib\toolbox folder to the VC++ include directories.

The brown sections are the things I've learned so far.

 

Comments and corrections are welcome.

 

Hagen

 

 

EDIT: Thanks Roberto for your prompt response.

Message 3 of 7
(5,330 Views)

Just a side note on your item #7.

 

Luis post you are referring to is dated 2004 ( Smiley Surprised ) : he is probably referring to CVI release 5 or 6.

In all versions of CVI from 7 on does exists toolbox\msvc folder (the same as several other msvc subfolders in CVI or Shared directories) that I suppose it is intended for Visual Studio users.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 7
(5,324 Views)

Thank you Roberto.

 

It seems to me, that although Luis post might be a bit outdated the problem still (or maybe again) exists in version 2010, which I am using.

 

You are right to mention the "msvc" folder under the CVIversion\toolslib\toolbox directory. In this folder there are files like toolbox.obj or cvixml.obj.

 

Nevertheless, if I link my program against these files, I get the exact same link errors described by Luis in his pretty old post. If I use the source files instead, I don't get any link errors and (almost) everything works just fine.

 

Now my problem with using the sources is, that the MSVC compiler generates a lot of warnings concerning these source files. Restrictions on software developement that are introduced by my company now force me to use the "Warnings as Errors" options in the compiler settings. So again it is pretty impossible for me to compile my project.

 

Again the link errors are:

 

Error	2	error LNK2001: unresolved external symbol "__ror64".	toolbox.obj
Error	3	error LNK2001: unresolved external symbol "__rol64".	toolbox.obj
Error	1	error LNK2001: unresolved external symbol "__mul64".	toolbox.obj
Error	5	error LNK2001: unresolved external symbol "__GetFilesArray".	toolbox.obj
Error	4	error LNK2001: unresolved external symbol "__GetErrno".	toolbox.obj
Error	6	error LNK1120: 5 unresolved externals.

I hope anyone can help my on this.

0 Kudos
Message 5 of 7
(5,281 Views)

Hello Hagen,

 

I definitely recommend that you include toolbox.c instead of toolbox.obj in your VC project. Object files are generally not portable across compilers, and a large module like toolbox is bound to have some of these incompatibilities. I understand that you have to eliminate all your source warnings, but you can do this fairly easily done, either via pragmas in the code (for example, "#pragma warning(disable:4133)") or in the project settings (Project >> ... Properties >> Configuration Properties >> C/C++ >> Advanced >> Disable Specific Warnings). Most of the warnings in toolbox.c should be 4133 and 4996. Both of these warnings are inocuous for the purposes of toolbox.c.

 

If you really need to use toolbox.obj, you can, but you're subject to future changes in CVI or VC that might require you to keep tweaking your project. As far as the 2010 versions are concerned, a couple of things have changed since that 2004 post (one in VC and one in CVI) that require the following modifications:

 

1. To account for a change in VC's implementation of stdin/stdout/stderr, you need to change the suggested wrappers to something like this:

 

#include "errno.h"
#include "stdio.h"

int _GetErrno (void)
{
    return errno;
}

FILE **_GetFilesArray (void)
{
    static FILE *wrapper_files[3] = {NULL, NULL, NULL};

    if (wrapper_files[0] == NULL)
    {
        wrapper_files[0] = stdin;
        wrapper_files[1] = stdout;
        wrapper_files[2] = stderr;
    }

    return wrapper_files;
}

 

2. To account for changes in toolbox since 2004, you need to add the attached .obj files to your VC project. These object files contain assembly implementations of 64-bit arithmetic operations that are normally built into the CVI compiler.

 

Luis

 

Message 6 of 7
(5,261 Views)

Thank you very, very much.

 

I've included these object files and that eliminated the remaining link errors.

 

So whether I use these object files or the source files is a matter of how oftern I intend to alter my "workarounds" (namely _GetErrno and _GetFilesArray - or are there even more to come in the future?). And I think you are right. I doubt that even in a few years, I still remember these lines of code and where they were implemented. So I thank you for your effort, but as you said yourself: I should stick with the sources.

 

To avoid the warnings concerning these source files, I decided to create a separate library file (toolslib.lib) that only contains these source files. This separates the warnings of these sources from the ones of my own project.

 

Hagen

0 Kudos
Message 7 of 7
(5,255 Views)