VC ++使用gumbo查询的问题(链接错误) [英] VC++ Problems using gumbo-query (linking error)

查看:1279
本文介绍了VC ++使用gumbo查询的问题(链接错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VC ++项目,我试图使用gumbo查询库的扩展,发现此处。此库封装/扩展了Google的gumbo解析器,此处。下面是我采取的具体步骤 - 我不是很熟悉导入库,所以我做了我做的使用Boost库:



在Visual Studio(VS社区2013)中,在项目设置 - >配置属性 - > C / C ++ - >常规我已经把路径到一个文件夹,包含来自上面链接的所有项目的源文件。具体来说,我放置了两个项目的src文件夹中的.c,.cpp和.h文件,并在我的项目设置中将这些文件作为include目录。



用于扩展Google gumbo解析器的项目的示例文件(在此处找到) ),我添加了这两行来导入库:

  #includeDocument.h
#include Node.h

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

  CDocument d; 

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

  1> Main.obj:error LNK2028:unresolved token(0A0003B7)public:__thiscall CDocument :: CDocument(void)(?? 0CDocument @@ $$ FQAE @ XZ)在函数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在函数private:void __clrcall中引用的@@ $$ FUAE @ XZ)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:未解析的外部符号public:__thiscall CDocument :: CDocument(void) (?System?Object?,class System :: ComponentModel :: DoWorkEventArgs ^)(?worker_DoWork())中引用的函数private:void __clrcall MyApplication :: Main :: worker_DoWork中引用的函数(?0CDocument @@ $$ FQAE @ XZ) @ Main @ MyApplication @@ $$ FA $ AAMXP $ AAVObject @ System @@ P $ AAVDoWorkEventArgs @ ComponentModel @ 4 @@ Z)
1> Main.obj:error LNK2019:未解析的外部符号public:virtual __thiscall CDocument在函数private:void __clrcall中引用的:::〜CDocument(void)(?? 1CDocument @@ $$ FUAE @ XZ)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:致命错误LNK1120:4未解决的外部

一个CDocument实例化。



我能做些什么来纠正? VS似乎认为包括都是罚款,和moreso当我把CDocument d;

解决方案

像往常一样,很明显我也是一个JS开发者长。我真的需要编译一个.lib文件。感谢基督徒提醒我。



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



接下来,我添加了来自wrapper库gumbo-query的额外源文件,其中我不得不修复来自原始gumbo解析器的parser.h / parser.cpp之间的命名冲突项目和包装器库中的Parser.h / Parser.cpp文件。我还将 #include 的所有引用更改为 #includegumbo.h p>

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


I've got a VC++ project, and I'm attempting to use the extension of the gumbo-query library, found here. This library wraps/extends Google's gumbo-parser found here. The following is the exact steps I've taken - I'm not very familiar with importing libraries, so I've done what I do to use the Boost libraries:

In Visual Studio (VS Community 2013), under the project settings -> Configuration Properties -> C/C++ -> General I have put the path to a folder that contains all of the source files from both of the projects linked above. Specifically, I placed the .c, .cpp and .h files from the src folder of both projects and referenced these in my projects settings as an include directory.

Following the example file for the project that extends Google's gumbo-parser (found here), I added these two lines to import the library:

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

At this point, my solution compiles fine. However, continuing to follow the example file, adding the first variable declaration:

CDocument d;

Causes a linker error, as follows:

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

This error appears to occur no matter where I put a CDocument instantiation.

What can I do to rectify this? VS seems to think the includes are fine, and moreso when I put in CDocument d; it lights up to show it recognises the CDocument type.

解决方案

As always, it's clear I've been a JS developer for too long. I really did need to compile a .lib file. Thank you to Christian for reminding me of this.

The original gumbo-parser project by Google includes a VS project. I opened this and compiled it, fixing all of the project settings problems so that I could import it into my project, which I did via the Configuration Properties -> Linker -> Input -> Additional Dependencies setting for my VS project.

Next, I added the extra source files from the wrapper library gumbo-query, where I had to fix a naming conflict between parser.h/parser.cpp from the original gumbo-parser project and the Parser.h/Parser.cpp file in the wrapper library. I also changed all references to #include <gumbo.h> to #include "gumbo.h"

Eventually, I got a gumbo.lib file containing both the original and the wrapper libraries, and this imported into my project and I now seem to be able to successfully use the functions.

这篇关于VC ++使用gumbo查询的问题(链接错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆