error: include location "/usr/include/" is unsafe for cross-compilation

2019-05-26 00:32:33 浏览数 (1)

今天在对minigui做交叉编译,下面是编译的部分脚本

代码语言:javascript复制
./configure 
	--host=$host 
	--with-runmode=ths 
	--prefix=$_prefix 
	|| exit -1
make -j8  || exit -1

如果不做交叉编译,host指定为当前机器的架构(x86_64-linux-gnu)则编译正常 如果设置为mips-linux-gnu进行交叉编译,就报错了:

代码语言:javascript复制
mips-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../../.. -I/home/gyd/workspace/app/dependencies/libminigui-3.2.0/src/include -I/home/gyd/workspace/app/dependencies/libminigui-3.2.0/include -I/home/gyd/workspace/app/dependencies/libminigui-3.2.0/src/newgal/ -I/usr/include/ -D_DEBUG -Wall -Werror -ffunction-sections -fdata-sections -D_WITH_TARGET_NONE -D__MINIGUI_LIB__ -D_REENTRANT -D_MG_ENABLE_SPLASH=1 -D_GNU_SOURCE -O2 -Wstrict-prototypes -pipe -MT pcxvfb.lo -MD -MP -MF .deps/pcxvfb.Tpo -c pcxvfb.c  -fPIC -DPIC -o .libs/pcxvfb.lo
cc1: error: include location "/usr/include/" is unsafe for cross-compilation [-Werror=poison-system-directories]
In file included from /home/gyd/workspace/app/dependencies/libminigui-3.2.0/include/common.h:2256:0,
                 from pcxvfb.c:43:
/usr/include/pthread.h:681:6: error: '__regparm__' attribute directive ignored [-Werror=attributes]
      __cleanup_fct_attribute;
      ^
/usr/include/pthread.h:693:3: error: '__regparm__' attribute directive ignored [-Werror=attributes]
   __cleanup_fct_attribute;
   ^
/usr/include/pthread.h:716:6: error: '__regparm__' attribute directive ignored [-Werror=attributes]
      __cleanup_fct_attribute;
      ^
/usr/include/pthread.h:729:3: error: '__regparm__' attribute directive ignored [-Werror=attributes]
   __cleanup_fct_attribute;
   ^
/usr/include/pthread.h:738:6: error: '__regparm__' attribute directive ignored [-Werror=attributes]
      ;
      ^
In file included from /usr/include/sys/select.h:30:0,
                 from /usr/include/sys/types.h:219,
                 from /usr/include/stdlib.h:314,
                 from pcxvfb.c:38:
pcxvfb.c: In function 'PCXVFB_VideoInit':
/usr/include/bits/select.h:36:5: error: inconsistent operand constraints in an 'asm'
     __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS         
     ^
/usr/include/sys/select.h:93:26: note: in expansion of macro '__FD_ZERO'
 #define FD_ZERO(fdsetp)  __FD_ZERO (fdsetp)
                          ^
pcxvfb.c:509:13: note: in expansion of macro 'FD_ZERO'
             FD_ZERO(&rset);
             ^
/usr/include/bits/select.h:36:5: error: inconsistent operand constraints in an 'asm'
     __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS         
     ^
/usr/include/sys/select.h:93:26: note: in expansion of macro '__FD_ZERO'
 #define FD_ZERO(fdsetp)  __FD_ZERO (fdsetp)
                          ^
pcxvfb.c:527:13: note: in expansion of macro 'FD_ZERO'
             FD_ZERO(&rset);
             ^
cc1: all warnings being treated as errors

上面一大堆错误,不用头晕,只要看第一个错误才是根源

cc1: error: include location “/usr/include/” is unsafe for cross-compilation [-Werror=poison-system-directories]

很显然在交叉编译环境下,Makefile 中不应该出现-I/usr/include/ 这样的参数,但它确实出现了

mips-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I…/…/… -I/home/gyd/workspace/app/dependencies/libminigui-3.2.0/src/include -I/home/gyd/workspace/app/dependencies/libminigui-3.2.0/include -I/home/gyd/workspace/facelock/dependencies/libminigui-3.2.0/src/newgal/ -I/usr/include/ -D_DEBUG -Wall -Werror -ffunction-sections -fdata-sections -D_WITH_TARGET_NONE -D__MINIGUI_LIB__ -D_REENTRANT -D_MG_ENABLE_SPLASH=1 -D_GNU_SOURCE -O2 -Wstrict-prototypes -pipe -MT pcxvfb.lo -MD -MP -MF .deps/pcxvfb.Tpo -c pcxvfb.c -fPIC -DPIC -o .libs/pcxvfb.lo

报错为pcxvfb.c:490:13: error: impossible constraint in ‘asm’,虽然错误信息不一样,其实是一回事儿,就是因为有-I/usr/include/。 这篇文章的作者的解决办法就是修改Makefile,删除/usr/include相关的代码。野蛮而有效。 但我总觉得哪里不对。这么明显的错误不应该存在于MiniGUI的发行版本中需要用户修改Makefile来解决问题 找到关于pcxvfb图形引擎的说明,如下图

上面的表格红框标注部分说得很明白:pc_xvfb 是Linux/Win32平台下适合 PC 的虚拟缓冲区图形引擎。 注意是虚拟缓冲区图形引擎,它是开发调试阶段使用的图形引擎。也就是说在为目标平台(本文中是mips)交叉编译二进制版本的时候,这个引擎根本就不用不上,所以它就不应该被编译。 minigui的编译配置中有pc_xvfb 的编译开关,执行./configure --help | grep pcxvfb就可以查到

代码语言:javascript复制
./configure --help | grep pcxvfb
  --enable-videopcxvfb     include PC Virtual FrameBuffer NEWGAL engine, such as qvfb, mvfb, gvfb or wvfb <default=yes>
  --enable-videortosxvfb   include RTOS Virtual FrameBuffer NEWGAL engine <default=no>. Please disable pcxvfb to enable rtosxvfb

于是在执行configure时果断加入--enable-videopcxvfb=no禁用videopcxvfb

代码语言:javascript复制
./configure 
	--host=$host 
	--with-runmode=ths 
	--prefix=$_prefix 
	--enable-videopcxvfb=no 
	|| exit -1
make -j8  || exit -1

再次编译就正常通过。

0 人点赞