有关在 htmlcxx 中查找'strings.h'的错误

Error about finding 'strings.h' in htmlcxx

本文关键字:strings 错误 查找 htmlcxx      更新时间:2023-10-16
#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;
 }

嗨,我正在使用htmlcxx,我安装了它,包括它的头文件和库到我的项目,并写了我的代码如上所述简而言之,我打开一个html文件,将其放入字符串中,然后使用html解析器进行编写。但是我得到了以下错误:

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

我想知道您是否可以帮我解决这个问题。**

我认为strings.h是一个unix头文件。基本上,字符串库有两个不同的头:string.hstrings.h。它们定义的原型略有不同。应该有一种适当的方法来使用宏来包含适当的宏来测试编译环境。就像

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

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

编辑:尝试这个快速而丑陋的修复:创建一个包含以下内容的文件strings.h:

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

这可能有效,取决于它们使用的函数…

编辑:

他们在ParserSax.tcc中使用这种宏:

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

所以这可能是您的mingw安装的问题。请尝试在您的系统中手动查找此文件