LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

[need assistance] error LNK2019: unresolved external symbol _CVIXMLLoadDocument

Solved!
Go to solution

I attempt to load an existing XML file and edit it with Microsoft Visual Studio 2008. Once I add the following function, I get the error LNK2019.

 

CVIXMLDocument doc = 0;

CVIXMLLoadDocument ("c:\\Temp\\AppTestCmd.xml", &doc); 

 

1>01_cpp_list.obj : error LNK2019: unresolved external symbol _CVIXMLLoadDocument@8 referenced in function _main
1>C:\sc\practice\01_cpp_list\Debug\01_cpp_list.exe : fatal error LNK1120: 1 unresolved externals

 

I try to add the files and lib mentioned in the following link, but they do not help.

http://forums.ni.com/t5/LabWindows-CVI/unresolved-external-symbol-MSXML-IXMLxxx/m-p/1127380/highligh...

 

How can I fix it? Thanks!

 

Here is the code piece. I have only one file in my MSVS project.

============================================================

#include <iostream>

#include <cvixml.h>
#include <msxmldom.h>
#include <cvirte.h> // NI CVI
#include <userint.h> // NI CVI
#include <utility.h>

using namespace std;

 

int main ()
{
     CVIXMLDocument doc = 0;

     CVIXMLLoadDocument ("c:\\Temp\\AppTestCmd.xml", &doc);

     return 0;
}

 

0 Kudos
Message 1 of 10
(11,665 Views)

Hi, 

 

It sounds like the error you are running into is similar to the one mentioned in this KnowledgeBase Article:

 

http://digital.ni.com/public.nsf/allkb/29F78F9CBDF35C5886256810007A4BA7

 

While this article references the PID Toolkit, the basic ideas are the same for adding any CVI functions to C++.  Try adding the lines of code mentioned in Step #10 to your header file.

 

 

Regards,

0 Kudos
Message 2 of 10
(11,635 Views)

Hi, Lindsey:

The step #10 mentioned in the link is about this:

 

#ifdef __cplusplus
extern "C" {
#endif

 

However, the XML toolbox function CVIXMLLoadDocument in this case is defined in <cvixml.h>, which has been embraced by extern "C" pair. I don't think this is the way to resolve this issue.

 

Thanks!

Brad L

0 Kudos
Message 3 of 10
(11,619 Views)

Hi,

 

Make sure you have included the following settings and files in your project:

 

1) Right-click on your application in Solution Explorer and select Properties.  On the left pane go to Configuration Properties >> C/C++ >> General.  Add the directories that contain the included header files to the “Additional Include Directories” list.

 

2) Include the following libraries in your project: cvirte.dll, cvisupp.lib, and cviwmain.lib

 

3) Include cvixml.c in the project as a source file.

 

4) Include cvixml.obj in the project.  This is ususally located in the "msvc" folder, which is located in the same directory as cvixml.h

 

 

Regards,

0 Kudos
Message 4 of 10
(11,584 Views)

Hi, 

The link to the following include path has been added by two ways in Microsoft Visual Studio 2008.

C:\Program Files (x86)\National Instruments\CVI2013\toolslib\toolbox

(1) [menu bar, Tools -> Options -> Projects and Solutions -> VC++ Directories -> Include files

(2) [menu bar, Project -> Configuration Properties -> C/C++ -> General -> Additional Include Directories

 

"cvisupp.lib" and "cviwmain.lib" are added to linker input. I cannot find this one in my NI folders "cvirte.dll".

 

In my MSVS project, add "cvixml.c" to the Source Files folder and "cvixml.obj" to the Resource Files folder.

 

With the above settings, it ends up with the following compilation error.

 

If we roll back to the initial code in the beginning of this discussion thread, we probably just miss one lib file or a few which contains CVIWindows XML function tree.

 

=========================================================

1>------ Build started: Project: 01_cpp_list, Configuration: Debug Win32 ------
1>Compiling...
1>01_ni_xml.cpp
1>cvixml.c
1>c:\sc2\01_practice_template\01_cpp_list\cvixml.c(153) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>c:\sc2\01_practice_template\01_cpp_list\cvixml.c(308) : error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>c:\sc2\01_practice_template\01_cpp_list\cvixml.c(1488) : error C2664: 'MSXML_IXMLDOMNamedNodeMapGetlength' : cannot convert parameter 3 from 'int *' to 'long *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\sc2\01_practice_template\01_cpp_list\cvixml.c(1534) : error C2664: 'MSXML_IXMLDOMNamedNodeMapGetlength' : cannot convert parameter 3 from 'int *' to 'long *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Generating Code...
1>Build log was saved at "file://c:\sc2\01_practice_template\01_cpp_list\01_cpp_list\Debug\BuildLog.htm"
1>01_cpp_list - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========

 

0 Kudos
Message 5 of 10
(11,560 Views)

Hi,

 

I have been able to reproduce the linking errors you are seeing.  I believe that the cvixml library is the only other one you need to include in your C++ project, but you need to actually compile it into a library to use it first.

 

This can be done in CVI as explained in the following KnowledgeBase Article:

 

http://digital.ni.com/public.nsf/allkb/9E1411A470C12C258625707E0008DB52

 

In addition to the steps outlined in this article, you will need to set a few other Target Settings.  Before building the dll, go to Build >> Target Settings and change the “Run-Time Support” option to “Full Run-Time Engine.”  Also click on the “Type Library” button and uncheck the “Add type library resource to dll” option.

 

 

This should create a cvixml dll, as well as .lib file.  You can then add the folder path to the .lib file to the Additional Dependencies field under Properties >> Configuration Properties >> Linker >> Input in your C++ project.

 

Make sure that you also have the cvisupp.lib and cviwmain.lib files linked in Additional Dependencies as we previously discussed.  Also, delete cvixml.c and cvixml.obj from your project.  With these settings, I was able to run the code you attached in your first post.

 

 

Regards,

0 Kudos
Message 6 of 10
(11,545 Views)

Following the instructions above, I cannot have "Create Release Dynamic Link Library" on my LabWindows Build menu. Please see the attached screen snapshot.

 

Here are my detailed configuration:

(1) copy these 3 files "cvixml.c", "cvixml.fp", "cvixml.h" and paste them to a folder, called xml

 

(2) Open "cvixml.fp", create a DLL project and load the DLL project now (as mentioned in the knowledge base How To Create a DLL from a LabWindows/CVI Instrument Driver), add "cvixml.c" and "cvixml.h" to the project.

 

(3) Set the Target on LabWindows as mentioned earlier:

   Build -> Target Settings -> Run-time support: "Full run-time engine"

   Build -> Target Settings -> Type Library: uncheck "Add type library resource to DLL"

 

(4) Set the followig (as mentioned in the knowledge base How To Create a DLL from a LabWindows/CVI Instrument Driver)

   Build -> Target type: "Dynamic Link Library"

   Build -> Configuration: "Release"

 

 

 

0 Kudos
Message 7 of 10
(11,511 Views)

Hi,

 

If you are using LabWindows/CVI 2013 or 2013 SP1, you will not have the option to "Create Release Dynamic Link Library."  Instead, you can just select Build»Build.  This will create the .dll and .lib files.

 

 

Regards,

0 Kudos
Message 8 of 10
(11,499 Views)
Solution
Accepted by Vineyard

Working now. Thanks for all kind assistance.

0 Kudos
Message 9 of 10
(11,478 Views)

The link can't be opened. Can you send it again

0 Kudos
Message 10 of 10
(5,442 Views)