全志TinaLinux編譯錯誤fatal error: unicode/ucnv.h: No such file or directory


今天開始正式干活了

拿到一個全志Tina的板子還有一個SDK壓縮包,要求我這周(只剩一天半。。。)就要把sdk編譯通過並且把板子跑起來。

還特別跟我說他們試了下這個sdk編譯沒法通過,會報錯。。。

竟然是有坑!

————————————————————————————————————————————————————————————————

准備工作:

拷貝解壓SDK

閱讀Guide手冊(如何配置環境,如何編譯,如何燒錄)

 

讀完了接下來正式開工

第一步,配置編譯環境。

但是老子是ssh遠程編譯服務器編譯,沒有全向apt-install,問老大,老大說應該配好了,叫我先編譯一下試試看。

應該?好吧,先略過。

第二步,編譯

還好編譯的時候回自動檢測編譯環境是否配置ok。

按照手冊開始一步一步編譯,問了下公司的服務器只有4核,為了不影響其他人使用,在這里只能make -j4編譯。

之后就是等待結果。。同時可以去找找燒錄套件准備硬件連接。

 $ tar -xvf Homlet-Tina-H2_H3
 $ cd Homlet-Tina-H2_H3
 $ source build/envsetup.sh
 $ lunch dolphin_p1-tina
 $ make –j4

 

編譯了大概13分鍾之后就Error報錯了!

停止編譯了!

In file included from /usr/include/libxml2/libxml/parser.h:810:0,
                 from /usr/include/libxml2/libxml/globals.h:18,
                 from /usr/include/libxml2/libxml/threads.h:35,
                 from /usr/include/libxml2/libxml/xmlmemory.h:218,
                 from /usr/include/libxml2/libxml/tree.h:1307,
                 from mxmlds.c:22:/usr/include/libxml2/libxml/encoding.h:31:26: fatal error: unicode/ucnv.h: No such file or directory
compilation terminated.
Makefile:393: recipe for target 'mxmlds.lo' failed
make[6]: *** [mxmlds.lo] Error 1
make[6]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/compile_dir/target/libmgncs-1.2.0/src/datasource'
Makefile:624: recipe for target 'install-recursive' failed
make[5]: *** [install-recursive] Error 1
make[5]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/compile_dir/target/libmgncs-1.2.0/src'
Makefile:487: recipe for target 'install-recursive' failed
make[4]: *** [install-recursive] Error 1
make[4]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/compile_dir/target/libmgncs-1.2.0'
Makefile:95: recipe for target '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/compile_dir/target/libmgncs-1.2.0/.built' failed
make[3]: *** [/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/compile_dir/target/libmgncs-1.2.0/.built] Error 2
make[3]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/package/minigui/libmgncs'
package/Makefile:192: recipe for target 'package/minigui/libmgncs/compile' failed
make[2]: *** [package/minigui/libmgncs/compile] Error 2
make[2]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3'
package/Makefile:189: recipe for target '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/staging_dir/target/stamp/.package_compile' failed
make[1]: *** [/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/out/dolphin-p1/staging_dir/target/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3'
Build failed - please re-run with -j1 to see the real error message
/home/liuxueneng/WorkCode/Homlet-Tina-H2_H3/build/toplevel.mk:275: recipe for target 'world' failed
make: *** [world] Error 1

#### make failed to build some targets (12:27 (mm:ss)) ####

看報錯是在編譯 libmgncs-1.2.0源碼包的mxmlds.c的時候跟蹤到encoding.h但是找不到被包含的頭文件unicode/ucnv.h

打開mxmlds.c看一下,含有以下幾個頭文件其中tree.h和parser.h都包含了encoding.h

#include <libxml/tree.h>                                                      
#include <libxml/xpath.h>                                                     
#include <libxml/parser.h>  

編譯該源碼包的時候指向的頭文件路徑是 /usr/include/libxml2/libxml/encoding.h

看下頭文件

/*                                                                            
   2  * Summary: interface for the encoding conversion functions                   
   3  * Description: interface for the encoding conversion functions needed for    
   4  *              XML basic encoding and iconv() support.                       
   5  *                                                                            
   6  * Related specs are                                                          
   7  * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies             
   8  * [ISO-10646]    UTF-8 and UTF-16 in Annexes                                 
   9  * [ISO-8859-1]   ISO Latin-1 characters codes.                               
  10  * [UNICODE]      The Unicode Consortium, "The Unicode Standard --            
  11  *                Worldwide Character Encoding -- Version 1.0", Addison-      
  12  *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is           
  13  *                described in Unicode Technical Report #4.                   
  14  * [US-ASCII]     Coded Character Set--7-bit American Standard Code for       
  15  *                Information Interchange, ANSI X3.4-1986.                    
  16  *                                                                            
  17  * Copy: See Copyright for the status of this software.                       
  18  *                                                                            
  19  * Author: Daniel Veillard                                                    
  20  */                                                                           
  21                                                                               
  22 #ifndef __XML_CHAR_ENCODING_H__                                               
  23 #define __XML_CHAR_ENCODING_H__                                               
  24                                                                               
  25 #include <libxml/xmlversion.h>                                                
  26                                                                               
  27 #ifdef LIBXML_ICONV_ENABLED                                                   
  28 #include <iconv.h>                                                            
  29 #endif                                                                        
  30 #ifdef LIBXML_ICU_ENABLED                                                     
  31 #include <unicode/ucnv.h>                                                     
  32 #endif                                                                        
  33 #ifdef __cplusplus                                                            
  34 extern "C" {                                                                  
  35 #endif          

發現里面有個宏 LIBXML_ICU_ENABLED開關控制unicode/ucnv.h的包含,控制ICU的功能是否需要enable。

現在報錯找不到unicode/ucnv.h說明這個宏被人定義了,但是在sdk目錄下搜索LIBXML_ICU_ENABLED 關鍵字的文件只有兩個,其中xmlversion.h明確屏蔽了這個宏

./package/allwinner/liballwinner_tina/liballwinner/LIBRARY/EXTERNAL/include/libxml/encoding.h
./package/allwinner/liballwinner_tina/liballwinner/LIBRARY/EXTERNAL/include/libxml/xmlversion.h
/**
 * LIBXML_ICU_ENABLED:
 *
 * Whether icu support is available
 */
#if 0
#define LIBXML_ICU_ENABLED
#endif

 

上面兩個文件和指定目錄的文件是同一個類型,只是不同版本,查看指定路徑頭文件/usr/include/libxml2/libxml/xmlversion.h,發現里面打開了這個宏。

/**                                                                           
 281  * LIBXML_ICU_ENABLED:                                                        
 282  *                                                                            
 283  * Whether icu support is available                                           
 284  */                                                                           
 285 #if 1                                                                         
 286 #define LIBXML_ICU_ENABLED                                                    
 287 #endif   

原本可以在指定的頭文件里屏蔽掉這個宏重新編譯就可以了。

但是這個是編譯服務器的系統頭文件

首先沒有權限修改。

其次為了編譯某個項目屏蔽公用的頭文件功能對別人使用會有影響。

最重要的是這個sdk編譯完了要打包燒錄到arm板子上,最好不要依賴牽涉宿主機上的東西,所有依賴自帶並打包才更符合邏輯。

--------------------------------------------------------------------------------------------------------------------------------------------------

問題原因找到了,解決辦法就是修改頭文件指定目錄。

現在需要找到頭文件路徑設置的地方進而修改。

 

整個sdk編譯走的都是Makefile結構,頭文件路徑有些是從父級環境變量繼承下來的,有些是子目錄源碼自己添加的。

查看出問題的源碼Makefile發現了CPPFLAGS里面就是包含了剛才那個系統頭文件目錄

 /usr/include/libxml2/libxml

但是改這個Makefile是沒有任何意義的,因為Makefile文件是configure之后自動產生的,所以這個應該問題和configure有關

看下源碼libmgncs-1.2.0目錄下的configure文件(重新解壓未編譯過的)果然發現了里面自帶的configure.as包含這個固定路徑

 

if test "x$build_datasource_xml" = "xyes"; then                               
     AC_DEFINE(_MGNCSDB_DATASOURCE, 1,                                         
         [Define if support datasource])                                       
     AC_DEFINE(_MGNCSDB_XML, 1,                                                
                 [Define if support xml datasource])                     
     CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
fi

現在只要把這個頭文件地址改到自己指定的libxml2目錄就可以了

CPPFLAGS="$CPPFLAGS -I../../../../package/allwinner/liballwinner_tina/liballwinner/LIBRARY/EXTERNAL/include/libxml"

重新configure 編譯就通過了。

 接下來就是准備燒錄驗證硬件了。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM