[英]Cross-compiling application and gcc using headers wrong headers
I'm attempting to cross-compile for an arm7 board using a toolchain on x86-64 Ubuntu. 我正在尝试使用x86-64 Ubuntu上的工具链交叉编译arm7板。 The headers I need are on the filesystem here: 我需要的标头位于文件系统上:
.../include/<libdir1>
.../include/<libdir2>
[more]
.../include/<libdirN>
but the .../include directory contains incompatible standard headers (for reasons I can't control). 但是... / include目录包含不兼容的标准头文件(出于我无法控制的原因)。 Using -I option causes gcc to use these incompatible standard headers rather than the ones it should. 使用-I选项会使gcc使用这些不兼容的标准标头,而不是应使用的标头。 Including all the compatible standard header paths with -I options prior to this also does not work. 在此之前用-I选项包括所有兼容的标准头文件路径也不起作用。
I want to use the same source paths for when I'm compiling natively and also for the arm7 board: 我要在本机编译时和arm7板上使用相同的源路径:
#include <libdir1/lib1.h>
#include <libdir2/lib2.h>
...
#include <libdirN/libN.h>
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? 有没有办法使用当前存在的文件系统来执行此操作,还是需要将lib1,lib2,... libN头文件完全复制到其他位置?
You could use the -iquote option for this: 您可以使用-iquote选项:
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 "file"'; they are not searched for
的情况下,将目录dir添加到要搜索头文件的目录列表的开头#include "file"'; they are not searched for
#include "file"'; they are not searched for
#include ', otherwise just like -I.#include "file"'; they are not searched for
#include',否则就像-I一样。
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>
And then add the directory with -iquote
rather than -I
: 然后用-iquote
而不是-I
添加目录:
-iquote../include
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.