c++ - MinGW 中的 fatal error : strtok_r. h : No such file or directory (while compiling tesseract-ocr-3. 01)

标签 c++ compiler-errors mingw tesseract

我在 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/

相关文章:

c++ - 使用 HTK(隐马尔可夫工具包)的 C/C++ 代码示例

c++ - 如何在不指定Unix 中所有C 编译器位置的情况下指定一个程序配置文件的位置?

c++ - CMAKE 找到包但不链接库

windows - 在 Windows 10 下使用 mingw 构建 OpenCV 时出错

compiler-errors - “make all” 编译TPlink wm722n驱动出错

c++ - SIGSEGV为什么不使过程崩溃?

java - 人脸特征检测——眼角、眉毛

c++ - 是否在异常期间为类中的 map 数据成员释放内存

c++ - 如何重构逻辑以更好地处理错误?

parsing - 解析编译错误时到达文件末尾