04-05-2011 03:50 AM - edited 04-05-2011 04:00 AM
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.
04-05-2011 04:33 AM
I don't know anything on Visual Studio, but toolbox.obj can be found in <cvifolder>\toolslib\toolbox\msvc folder
04-05-2011 04:41 AM - edited 04-05-2011 04:46 AM
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😞
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. |
Note Import library files for National Instruments hardware libraries might be located in CVIversion\extlib and not within the msvc or msvc64 folders. |
The brown sections are the things I've learned so far.
Comments and corrections are welcome.
Hagen
EDIT: Thanks Roberto for your prompt response.
04-05-2011 05:09 AM
Just a side note on your item #7.
Luis post you are referring to is dated 2004 ( ) : 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.
04-13-2011 02:36 AM
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.
04-13-2011 05:46 PM
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
04-14-2011 12:49 AM
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