LNK2019 for XmlLite
-
Hi, I am using VS2008 SP1 On Widows 7 X64, once I have decided to use the XmlLite parser in my program I faced the following problem
Error 1 error LNK2019: unresolved external symbol _CreateXmlReader@12 referenced in function
"public: void __thiscall CXmlLiteSampleAppDlg::OnBnClickedButtonOpenXmlFile(void)"
(?OnBnClickedButtonOpenXmlFile@CXmlLiteSampleAppDlg@@QAEXXZ) XmlLiteSampleAppDlg.objand here is my code:
void CXmlLiteSampleAppDlg::OnBnClickedButtonOpenXmlFile()
{CFileDialog fDlg(true,L"xml",NULL, OFN\_PATHMUSTEXIST | OFN\_FILEMUSTEXIST | OFN\_EXPLORER, L"XML Files (\*.xml)|\*.xml||", this,NULL,true); if(fDlg.DoModal()==IDOK){ CString fileName(fDlg.GetPathName()); ::SHCreateStreamOnFileW(fileName, STGM\_READWRITE | STGM\_SHARE\_DENY\_WRITE,&m\_pFileStream); HRESULT hr = ::CreateXmlReader( \_\_uuidof(IXmlReader),reinterpret\_cast<void\*\*>(&m\_pXMLReader),NULL); if(FAILED(hr)){ \_com\_error err(hr); ::AfxMessageBox(err.ErrorMessage()); return; } }//DoModal()
}
and my definitions of IStream and IXmlReader is like below:
CComPtr <IStream> m_pFileStream;
CComPt <IXmlReader> m_pXMLReader;Of course while surfing the net I find similar problem in this thread: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/fad815c9-0de3-4c97-a6a6-12d04a958013 and I have done all solution discussed there but non of them solve my problem. Also I have added
$(WindowsSdkDir)\lib
to the C++ Directories but this effort were in vain too.
-
Hi, I am using VS2008 SP1 On Widows 7 X64, once I have decided to use the XmlLite parser in my program I faced the following problem
Error 1 error LNK2019: unresolved external symbol _CreateXmlReader@12 referenced in function
"public: void __thiscall CXmlLiteSampleAppDlg::OnBnClickedButtonOpenXmlFile(void)"
(?OnBnClickedButtonOpenXmlFile@CXmlLiteSampleAppDlg@@QAEXXZ) XmlLiteSampleAppDlg.objand here is my code:
void CXmlLiteSampleAppDlg::OnBnClickedButtonOpenXmlFile()
{CFileDialog fDlg(true,L"xml",NULL, OFN\_PATHMUSTEXIST | OFN\_FILEMUSTEXIST | OFN\_EXPLORER, L"XML Files (\*.xml)|\*.xml||", this,NULL,true); if(fDlg.DoModal()==IDOK){ CString fileName(fDlg.GetPathName()); ::SHCreateStreamOnFileW(fileName, STGM\_READWRITE | STGM\_SHARE\_DENY\_WRITE,&m\_pFileStream); HRESULT hr = ::CreateXmlReader( \_\_uuidof(IXmlReader),reinterpret\_cast<void\*\*>(&m\_pXMLReader),NULL); if(FAILED(hr)){ \_com\_error err(hr); ::AfxMessageBox(err.ErrorMessage()); return; } }//DoModal()
}
and my definitions of IStream and IXmlReader is like below:
CComPtr <IStream> m_pFileStream;
CComPt <IXmlReader> m_pXMLReader;Of course while surfing the net I find similar problem in this thread: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/fad815c9-0de3-4c97-a6a6-12d04a958013 and I have done all solution discussed there but non of them solve my problem. Also I have added
$(WindowsSdkDir)\lib
to the C++ Directories but this effort were in vain too.
Scott McPhillips solve my problem in msdn forums so I would put it here: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/719633c2-ff39-4c3d-84fd-2ca745524eab[^] and the answer: you have to add the xmllite.lib file to your project dependencies. 1.In the Solution Explorer, right click on the project and select Properties. 2.In the tree, expand Configuration Properties, and then expand Linker. 3.Under Linker, click on Input. Enter xmllite.lib for Additional Dependencies. 4.Click OK.
-
Scott McPhillips solve my problem in msdn forums so I would put it here: http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/719633c2-ff39-4c3d-84fd-2ca745524eab[^] and the answer: you have to add the xmllite.lib file to your project dependencies. 1.In the Solution Explorer, right click on the project and select Properties. 2.In the tree, expand Configuration Properties, and then expand Linker. 3.Under Linker, click on Input. Enter xmllite.lib for Additional Dependencies. 4.Click OK.
The missing symbol the compiler was looking for was CreateXmlReader, I know the compiler indicated that the problem was in your dialog class, it's a common red herring, but once you know how to read these linker error messages, it gets easier :-) If adding a library path instead (if all you have is the .lib file), you will want to check that the library is added for debug and release builds. Configuring a project dependency as in the previous solution is thus best.
Conrad - The world waits for you to stick your neck out, it's not easy. But once you actually stand up, you do get noticed. http://www.plcsimulator.org/