使用标头交叉编译应用程序和gcc错误的标头 [英] Cross-compiling application and gcc using headers wrong headers
问题描述
我正在尝试使用x86-64 Ubuntu上的工具链交叉编译arm7板。我需要的标头在这里的文件系统上:
I'm attempting to cross-compile for an arm7 board using a toolchain on x86-64 Ubuntu. The headers I need are on the filesystem here:
.../include/<libdir1>
.../include/<libdir2>
[more]
.../include/<libdirN>
但是... / include目录包含不兼容的标准头文件(出于我无法控制的原因) 。使用-I选项会使gcc使用这些不兼容的标准标头,而不是应使用的标头。在此之前使用-I选项包括所有兼容的标准标头路径也不起作用。
but the .../include directory contains incompatible standard headers (for reasons I can't control). Using -I option causes gcc to use these incompatible standard headers rather than the ones it should. Including all the compatible standard header paths with -I options prior to this also does not work.
我想使用相同的源路径进行本机编译和arm7开发板使用:
I want to use the same source paths for when I'm compiling natively and also for the arm7 board:
#include <libdir1/lib1.h>
#include <libdir2/lib2.h>
...
#include <libdirN/libN.h>
是否可以使用当前存在的文件系统来执行此操作,或者是否需要复制lib1,lib2,... libN头文件完全在其他地方吗?
Is there a way to do this using the filesystem as it currently exists or do I need to copy the lib1, lib2, ... libN header files somewhere else entirely?
推荐答案
您可以使用-iquote 选项:
仅在
#include file'的情况下,将目录dir添加到要搜索头文件的目录列表的开头;不会搜索
#include,否则就像-I一样。
Add the directory dir to the head of the list of directories to be searched for header files only for the case of
#include "file"'; they are not searched for
#include ', otherwise just like -I.
因此,您将使用
样式的自定义标头包括include指令:
So you would include your custom headers with ""
style include directives:
#include "libdir1/lib1.h"
#include "libdir2/lib2.h"
但是具有<>
样式的标准标头:
But the standard headers with <>
style:
#include <stdlib.h>
然后使用 -iquote
添加目录而不是 -I
:
And then add the directory with -iquote
rather than -I
:
-iquote../include
这篇关于使用标头交叉编译应用程序和gcc错误的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!