Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual c++ 创建使用PugiXml的静态库时未解析的外部_Visual C++_Pugixml - Fatal编程技术网

Visual c++ 创建使用PugiXml的静态库时未解析的外部

Visual c++ 创建使用PugiXml的静态库时未解析的外部,visual-c++,pugixml,Visual C++,Pugixml,我正在编写一个静态库,它使用PugiXml进行xml解析。以下是Visual Studio 2010的链接器输出(为了便于阅读,我已将符号替换为省略号): 错误LNK2019:函数“private:bool\u thiscall Dae\u Doc::ParseDae(void)”(…)中引用了未解析的外部符号“public:\u thiscall Dae\u Library::Dae\u Library(void)”(…) 错误LNK2019:^“public:wchar_t const*_t

我正在编写一个静态库,它使用PugiXml进行xml解析。以下是Visual Studio 2010的链接器输出(为了便于阅读,我已将符号替换为省略号):

错误LNK2019:函数“private:bool\u thiscall Dae\u Doc::ParseDae(void)”(…)中引用了未解析的外部符号“public:\u thiscall Dae\u Library::Dae\u Library(void)”(…)
错误LNK2019:^“public:wchar_t const*_thiscall pugi::xml_node::name(void)const”(…)在函数“private:bool_uthiscall Dae_Doc::ParseDae(void)”中引用(…)
错误LNK2001:^“public:wchar\u t const*\u thiscall pugi::xml\u node::name(void)const”(…)
错误LNK2019:^“public:wchar_t const*_thiscall pugi::xml_attribute::value(void)const”(…)在函数“public:void_uthiscall Dae_Node::SetXmlNode(类pugi::xml_Node&)”中引用(…)
错误LNK2019:^“public:class pugi::xml_attribute uu thiscall pugi::xml_node::attribute(wchar_const*)const”(…)在函数“public:void u thiscall Dae_node::SetXmlNode(class pugi::xml_node&)”中引用(…)
我尝试过的事情:

  • 显式实例化我的模板类
  • 将PugiXml源代码链接到测试项目中(它当前与我正在构建的静态库一起)
  • 将PugiXml构建为静态库并在我的库项目和测试项目中引用它
  • 编写DoNothing函数来代替我的纯虚拟函数
  • 提供根本不引用pugixml的默认构造函数
在过去的两天里,这让我发疯,我真的不知道该怎么办。如果有人能给我任何指导,我将不胜感激

编辑:
值得注意的是,创建一个使用pugixml的简单静态库可以很好地编译和测试,因此我编写模板和类的方式可能有问题?

从错误消息中可以看出,您设置的pugixml\u WCHAR\u模式不一致

很可能您正在项目配置中设置它,并按原样使用pugixml发行版中脚本/文件夹中的一个捆绑vcproj文件


此定义控制pugixml中使用的字符类型(char或wchar_t);对于pugixml.cpp和使用pugixml的代码,必须以相同的方式进行设置-建议在pugiconfig.hpp中进行设置,或者确保在所有包含pugixml.hpp的源文件的项目中都启用该选项。在您的情况下,如果不想修改pugiconfig.hpp,则必须更改pugixml静态库的vcproj。

从错误消息中可以看出,您设置的pugixml\u WCHAR\u模式不一致

很可能您正在项目配置中设置它,并按原样使用pugixml发行版中脚本/文件夹中的一个捆绑vcproj文件


此定义控制pugixml中使用的字符类型(char或wchar_t);对于pugixml.cpp和使用pugixml的代码,必须以相同的方式进行设置-建议在pugiconfig.hpp中进行设置,或者确保在所有包含pugixml.hpp的源文件的项目中都启用该选项。在您的情况下,如果不想修改pugiconfig.hpp,则必须更改pugixml静态库的vcproj。

您确定pugixml库DLL位于链接器可以找到它的默认位置吗?@H2CO3我没有将pugixml用作DLL。它是以源代码的形式分发的,要使用它,只需将其添加到项目中即可。当我将它用作静态库时,我设置了正确的路径。你确定PugiXml库DLL位于链接器可以找到它的默认位置吗?@H2CO3我没有将PugiXml用作DLL。它是以源代码的形式分发的,要使用它,只需将其添加到项目中即可。当我将它用作静态库时,我确实设置了正确的路径。这就解决了这个问题!非常感谢,但是现在我在我的模板类构造函数和析构函数上得到了未解析的外部函数…让它工作起来了。self注意:在编写模板时,将所有内容都内联。再次感谢zeuxcg!这就解决了这个问题!非常感谢,但是现在我在我的模板类构造函数和析构函数上得到了未解析的外部函数…让它工作起来了。self注意:在编写模板时,将所有内容都内联。再次感谢zeuxcg!
error LNK2019: unresolved external symbol "public: __thiscall Dae_Library<class Dae_Geometry>::Dae_Library<class Dae_Geometry>(void)" (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...) referenced in function "private: bool __thiscall Dae_Doc::ParseDae(void)" (...)
error LNK2001: ^ "public: wchar_t const * __thiscall pugi::xml_node::name(void)const " (...)
error LNK2019: ^ "public: wchar_t const * __thiscall pugi::xml_attribute::value(void)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)
error LNK2019: ^ "public: class pugi::xml_attribute __thiscall pugi::xml_node::attribute(wchar_t const *)const " (...) referenced in function "public: void __thiscall Dae_Node::SetXmlNode(class pugi::xml_node &)" (...)