2013-03-19 45 views
0
#include <iostream> 
#include <fstream> 
#include <cstdlib> 
#include <sstream> 
#include <string> 
#include <ParserDom.h> 
using namespace std; 

using namespace htmlcxx; 

int main() 
{ 

ifstream bucky; 
string str=""; 
    bucky.open("C:\\tasks\\TEST2.txt"); 

if(!bucky.is_open()){ 
    exit(EXIT_FAILURE); 
} 
char word[50]; 
bucky >> word; 
str.append(word); 
str.append(" ");  
while(bucky.good()) 
{ 

    bucky >> word; 
    str.append(word); 
    str.append(" "); 
    } 

//cout<< word<<" "<<endl; 
bucky >> word; 
str.append(word); 
str.append(" "); 

HTML::ParserDom parser; 
tree<HTML::Node> dom = parser.parseTree(str); 
//Print whole DOM tree 
cout << dom << endl; 
} 

喜找到“strings.h”中以,我使用htmlcxx,我安装了它,包括它的头文件和库到我的项目,并写了我的代码如上 简单地说,我打开了一个html文件,将其放入字符串中,然后使用html解析器编写它。但我得到了以下错误:错误有关htmlcxx

c:\...\htmlcxx-0.84\html\parsersax.tcc(4): fatal error C1083: Cannot open include file: 'strings.h': No such file or directory 

我知道你能不能帮我解决这个问题**

+0

你的构建环境是什么? – 2013-03-20 00:02:48

+0

在Microsoft Visual Studio C++中。我添加了#include 的标题,但仍显示错误消息。问题是它找不到strings.h! – user2188591 2013-03-20 18:43:01

回答

0

我觉得strings.h是UNIX的头文件。基本上,字符串库有两个不同的标头:string.hstrings.h。那些定义略有不同的原型。应该有一个合适的方法来使用宏来包含合适的宏来测试你的编译环境。就像

#ifdef _WIN32 
#include <string.h> 
#else 
#include <strings.h> 
#endif 

我不知道哪一个是Windows标准,这只是一个例子。如果您使用第三方代码,则可能不便携。你应该看看他们的头文件,看看他们是否使用了上面的代码。

编辑: 试试这个快速和丑陋的解决办法:创建一个文件strings.h其中constains:

extern "C" { 
#include <string.h> 
} 

可能的工作,根据其功能,他们使用......

编辑:

他们使用这种宏在ParserSax.tcc

#if !defined(WIN32) || defined(__MINGW32__) 
#include <strings.h> 
#endif 

所以它可能是你的mingw安装的问题。尝试在系统上手动查找此文件。

+0

谢谢,但它仍然显示我相同的错误信息! – user2188591 2013-03-20 18:44:14

+0

嗯,是的。我没有提供修复它,只是原因;)现在编辑 – Thibaut 2013-03-20 18:54:05

+0

但为什么错误与parsersax.tcc相关,它告诉我们无法打开strings.h?我已经在我的代码头中使用了string.h。我试图编写代码,但我仍然有错误。 – user2188591 2013-03-24 06:22:09