使用gumbo-query的VC ++问题(链接错误)

时间:2015-04-24 05:53:12

标签: c++ compiler-errors unresolved-external

我有一个VC ++项目,我正在尝试使用gumbo查询库的扩展,找到here。这个库包含/扩展了Google的gumbo-parser here。以下是我采取的确切步骤 - 我对导入库不是很熟悉,所以我已经完成了使用Boost库所做的工作:

在Visual Studio(VS Community 2013)中,在项目设置下 - >配置属性 - > C / C ++ - >一般我已将路径放到一个文件夹,其中包含上面链接的两个项目的所有源文件。具体来说,我放置了两个项目的src文件夹中的.c,.cpp和.h文件,并在我的项目设置中将它们作为包含目录引用。

按照扩展Google的gumbo-parser(found here)的项目的示例文件,我添加了这两行来导入库:

#include "Document.h"
#include "Node.h"

此时,我的解决方案编译得很好。但是,继续关注示例文件,添加第一个变量声明:

CDocument d;

导致链接器错误,如下所示:

1>Main.obj : error LNK2028: unresolved token (0A0003B7) "public: __thiscall CDocument::CDocument(void)" (??0CDocument@@$$FQAE@XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork@Main@MyApplication@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)
1>Main.obj : error LNK2028: unresolved token (0A0003B8) "public: virtual __thiscall CDocument::~CDocument(void)" (??1CDocument@@$$FUAE@XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork@Main@MyApplication@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall CDocument::CDocument(void)" (??0CDocument@@$$FQAE@XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork@Main@MyApplication@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)
1>Main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CDocument::~CDocument(void)" (??1CDocument@@$$FUAE@XZ) referenced in function "private: void __clrcall MyApplication::Main::worker_DoWork(class System::Object ^,class System::ComponentModel::DoWorkEventArgs ^)" (?worker_DoWork@Main@MyApplication@@$$FA$AAMXP$AAVObject@System@@P$AAVDoWorkEventArgs@ComponentModel@4@@Z)
1>..{omitted}..\MyApplication.exe : fatal error LNK1120: 4 unresolved externals

无论我在何处放置CDocument实例,都会出现此错误。

我该怎么做才能纠正这个问题? VS似乎认为包含很好,而且当我放入CDocument d时也是如此;它点亮以显示它识别CDocument类型。

1 个答案:

答案 0 :(得分:1)

与往常一样,很明显我是一名JS开发人员已经很久了。我确实需要编译一个.lib文件。感谢Christian提醒我这件事。

Google最初的gumbo-parser项目包括一个VS项目。我打开它并编译它,修复所有项目设置问题,以便我可以将它导入我的项目,我通过配置属性 - >链接器 - >输入 - >我的VS项目的附加依赖项设置。

接下来,我从包装库gumbo-query中添加了额外的源文件,在那里我必须修复来自原始gumbo-parser项目的parser.h / parser.cpp与Parser.h / Parser之间的命名冲突。包装器库中的cpp文件。我还将所有对#include <gumbo.h>的引用更改为#include "gumbo.h"

最终,我得到了一个包含原始库和包装库的gumbo.lib文件,并将其导入到我的项目中,现在我似乎能够成功使用这些函数。

相关问题