Resolve “liveMedia/include/Locale.hh:47:10: fatal error: xlocale.h: No such file or directory”

时间:2019-02-19
本文章向大家介绍Resolve “liveMedia/include/Locale.hh:47:10: fatal error: xlocale.h: No such file or directory”,主要包括Resolve “liveMedia/include/Locale.hh:47:10: fatal error: xlocale.h: No such file or directory”使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1. Question

        When I use Ubuntu18.04 desktop operating system to compile "Onenet Video SDK"(https://github.com/cm-heclouds/video_sdk),I encountered an problem as below:

[ 34%] Building CXX object sample/live/CMakeFiles/livertsp_s.dir/liveMedia/Locale.cpp.o
In file included from /home/yulong/onenet_VIDEO/video_sdk/sample/live/liveMedia/Locale.cpp:22:0:
/home/yulong/onenet_VIDEO/video_sdk/sample/live/liveMedia/include/Locale.hh:47:10: fatal error: xlocale.h: No such file or directory
 #include <xlocale.h> // because, on some systems, <locale.h> doesn't include <xlocale.h>; this makes sure that we get both
          ^~~~~~~~~~~
compilation terminated.
sample/live/CMakeFiles/livertsp_s.dir/build.make:1718: recipe for target 'sample/live/CMakeFiles/livertsp_s.dir/liveMedia/Locale.cpp.o' failed
make[2]: *** [sample/live/CMakeFiles/livertsp_s.dir/liveMedia/Locale.cpp.o] Error 1
CMakeFiles/Makefile2:335: recipe for target 'sample/live/CMakeFiles/livertsp_s.dir/all' failed
make[1]: *** [sample/live/CMakeFiles/livertsp_s.dir/all] Error 2 

 

2. Analysis:

        We can open /home/yulong/onenet_VIDEO/video_sdk/sample/live/liveMedia/include/Locale.hh, from line 47 we can see below:

        So it is apparently the trouble is because in our system there is neither locale.h nor xlocale.h.

 

3. Resolution 

         We can add "-DLOCALE_NOT_USED" to compile options.  If we use CMake tool to help compile, we can just add an "-DXLOCALE_NOT_USED" to definitions:
add_definitions(-DXLOCALE_NOT_USED)
        Job done. 

 

 4.  Summarize knowledge

      locale.h is a C programming standard library header file, it proclaim the C language localization functions which usually help multi-language software programming design.