minigui:mgplus交叉编译警告 include location "/usr/include/freetype2" is unsafe for cross-compilation

版权声明:本文为博主原创文章,转载请注明源地址。 https://blog.csdn.net/10km/article/details/83088803

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

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

export PATH=$freetype_prefix/bin:$PATH

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

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

猜你喜欢

转载自blog.csdn.net/10km/article/details/83088803