gpt4 book ai didi

c++ - 关于在 htmlcxx 中查找 'strings.h' 的错误

转载 作者:行者123 更新时间:2023-11-28 07:42:31 25 4
gpt4 key购买 nike

#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.84\html\parsersax.tcc(4): fatal error C1083: Cannot open include file: 'strings.h': No such file or directory

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

最佳答案

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

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

我不知道 Windows 上哪个是标准的,这只是一个例子。如果您使用第三方代码,它可能不可移植。您应该查看他们的 header ,看看他们是否使用与上面类似的代码。

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

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

这可能行得通,具体取决于他们使用的功能...

编辑:

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

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

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

关于c++ - 关于在 htmlcxx 中查找 'strings.h' 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15512790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com