mingw32-make ERROR, error: 'once_flag' in namespace 'std' does not name a type

匿名 (未验证) 提交于 2019-12-03 01:06:02

问题:

c:\libapiai-master\libapiai-master\build\examples>mingw32-make install mingw32-make install [  5%] Built target indent_stream_library [ 10%] Built target cJson [ 12%] Building CXX object apiai/CMakeFiles/apiai.dir/src/AI.cpp.obj C:\libapiai-master\libapiai-master\apiai\src\AI.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]  #include <apiai/AI.h>  ^ C:\libapiai-master\libapiai-master\apiai\src\AI.cpp: In static member function 'static ai::Service& ai::AI::sharedService()': C:\libapiai-master\libapiai-master\apiai\src\AI.cpp:42:12: error: 'once_flag' in namespace 'std' does not name a type      static std::once_flag once_flag;             ^ C:\libapiai-master\libapiai-master\apiai\src\AI.cpp:45:5: error: 'call_once' is not a member of 'std'      std::call_once(once_flag, [](){      ^ C:\libapiai-master\libapiai-master\apiai\src\AI.cpp:45:20: error: 'once_flag' was not declared in this scope      std::call_once(once_flag, [](){                     ^ apiai\CMakeFiles\apiai.dir\build.make:62: recipe for target 'apiai/CMakeFiles/apiai.dir/src/AI.cpp.obj' failed mingw32-make[16]: *** [apiai/CMakeFiles/apiai.dir/src/AI.cpp.obj] Error 1 CMakeFiles\Makefile2:179: recipe for target 'apiai/CMakeFiles/apiai.dir/all' failed mingw32-make[15]: *** [apiai/CMakeFiles/apiai.dir/all] Error 2 Makefile:137: recipe for target 'all' failed mingw32-make[14]: *** [all] Error 2 

I built api.ai library. I used MinGW to that. I made Makefile, but I made new error too. What is the problem?

回答1:

MinGW (but not MinGW-w64) does not currently support the full pthread interface, including std::once_flag.

You should switch to MinGW-w64 (pthread support) or use the Win32 API. Furthermore, MinGW with mingw-std-threads, you can have partial threading support.



回答2:

You did not pass the -std=c++11 flag.



回答3:

Check your mingw version, maybe it doesn't support 'once'. Or maybe 'once' contains in another header. Report issue to github, I'll try to resolve it. https://github.com/api-ai/libapiai



回答4:

I tried this workraound and it worked for me:

make the modification on detection_based_tracker.cpp

//#if (defined(__cplusplus) && __cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1700) //#define USE_STD_THREADS //#endif



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!