我在 MinGW 中编译 tesseract-ocr-3.01,我收到这个错误 ambigs.cpp:31:22: fatal error: strtok_r.h: No such file or directory
这是错误所在的代码:
#ifdef WIN32
#ifndef __GNUC__
#define strtok_r strtok_s
#else
#include "strtok_r.h"
#endif /* __GNUC__ */
#endif /* WIN32 */
编辑
我发现这个功能请求到 add strtok_r.h to MinGW .从那里的评论:
strtok_r() is an optional POSIX function, required only for implementations which support POSIX threads. MinGW does not support POSIX threads; therefore, I don't think that this function has any place in a base MinGW distribution.
POSIX threads support for MS-Windows is provided by the pthreads-win32 project. Maybe they already provide a strtok_r() implementation. If so, then you could use it; if not, you might ask them to consider adding it.
最佳答案
这个问题最容易通过添加 strtok_r implementation 来解决。到项目的来源:
char *strtok_r(char *str, const char *delim, char **save)
{
char *res, *last;
if( !save )
return strtok(str, delim);
if( !str && !(str = *save) )
return NULL;
last = str + strlen(str);
if( (*save = res = strtok(str, delim)) )
{
*save += strlen(res);
if( *save < last )
(*save)++;
else
*save = NULL;
}
return res;
}
关于c++ - MinGW 中的 fatal error : strtok_r. h : No such file or directory (while compiling tesseract-ocr-3. 01),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12973750/