前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >minigui:mgplus交叉编译警告 include locationi

minigui:mgplus交叉编译警告 include locationi

作者头像
10km
发布2019-05-25 20:39:11
8280
发布2019-05-25 20:39:11
举报
文章被收录于专栏:10km的专栏10km的专栏

版权声明:本文为博主原创文章,转载请注明源地址。 https://cloud.tencent.com/developer/article/1433456

今天在交叉编译mingui的mgplus组件库时输出了一个警告:

代码语言:javascript
复制
mips-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I../.. -D__MGPLUS_LIB__ -I.. -I../agg 
-I../../include -I../agg/font_freetype -ffunction-sections -fdata-sections 
-I/home/gyd/workspace/app/dependencies/release/freetype-2.6.1/mips-linux-gnu/include/freetype2 
-I/home/gyd/workspace/app/dependencies/release/libpng-1.2.59/mips-linux-gnu/include/libpng12 
-I/home/gyd/workspace/app/dependencies/release/zlib-1.2.11/mips-linux-gnu/include 
-I/home/gyd/workspace/app/dependencies/release/libminigui-3.2.0/mips-linux-gnu/include 
-DNDEBUG 
-I/usr/include/freetype2 
-g -O2 -MT lf_fashion.lo -MD -MP -MF .deps/lf_fashion.Tpo -c lf_fashion.cpp  -fPIC -DPIC -o .libs/lf_fashion.lo
cc1plus: warning: include location "/usr/include/freetype2" is unsafe for cross-compilation [-Wpoison-system-directories]

显然是configure生成的交叉编译Makefile文件中添加了了不该有的-I/usr/include/freetype2参数,为什么会这样呢?

为了追根溯源,我查看了mgplus项目根目录下的用于生成Makefileconfigure.ac的代码:

如上图红框标的代码,mgplus在生成Makefile时需要freetype的CFLAGS和LDFLAGS参数,但是它没有用标准的pkg-config命令(pkg-config --cflags freetype2,pkg-config --libs freetype2)来获取,而是用freetype提供的脚本工具 freetype-config来获取CFLAGS和LDFLAGS参数。所以在交叉编译时,如果没有将交叉编译的freetype安装路径bin文件夹加入到执行程序搜索路径环境变量$PATH,那么freetype-config --cflags返回的就是当前系统中安装的freetype的include位置/usr/include/freetype2.于是就出现了上面的警告。

解决办法也很简单在编译目标平台版本时要将交叉编译的freetype2的可执行文件夹bin加入$PATH

代码语言:javascript
复制
export PATH=$freetype_prefix/bin:$PATH

这样以来,Makefile中就freetype的include位置正确了,就不会再有这个警告

代码语言:javascript
复制
mips-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I../.. -D__MGPLUS_LIB__ -I.. 
-I../agg -I../../include -I../agg/font_freetype -ffunction-sections -fdata-sections 
-I/home/gyd/workspace/app/dependencies/release/freetype-2.6.1/mips-linux-gnu/include/freetype2 
-I/home/gyd/workspace/app/dependencies/release/libpng-1.2.59/mips-linux-gnu/include/libpng12 
-I/home/gyd/workspace/app/dependencies/release/zlib-1.2.11/mips-linux-gnu/include 
-I/home/gyd/workspace/app/dependencies/release/libminigui-3.2.0/mips-linux-gnu/include 
-DNDEBUG 
-I/home/gyd/workspace/app/dependencies/release/freetype-2.6.1/mips-linux-gnu/include/freetype2 
-g -O2 -MT opt_rgba32.lo -MD -MP -MF .deps/opt_rgba32.Tpo -c opt_rgba32.cpp  -fPIC -DPIC -o .libs/opt_rgba32.lo
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年10月16日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档