3

我正在尝试移植一个 Linux 库以在 VxWorks 上运行。我已成功构建 binutils 和 gcc 以针对i486-wrs-vxworks,并且可以成功构建一个简单的 C 程序。但是,当我尝试编译 C++ 时,事情就坏了。

我有一个简单的 Hello World 程序:

#include <string>
#include <iostream>
int main()
{
    std::string s = "Hello World";
    std::cout << s << std::endl;
    return 0;
}

为了构建它,我调用:

i486-wrs-vxworks-gcc -I/home/kyle/vxworks-6.9/target/usr/h -I/home/kyle/vxworks-6.9/target/usr/h/c++ hello.cpp

这总是失败并显示以下消息:

In file included from /home/kyle/vxworks-6.9/target/usr/h/c++/cerrno:4:0,
             from /home/kyle/vxworks-6.9/target/usr/h/c++/xlocnum:4,
             from /home/kyle/vxworks-6.9/target/usr/h/c++/ios:4,
             from /home/kyle/vxworks-6.9/target/usr/h/c++/ostream:4,
             from /home/kyle/vxworks-6.9/target/usr/h/c++/istream:4,
             from /home/kyle/vxworks-6.9/target/usr/h/c++/string:4,
             from hello.cpp:1:
/usr/local/lib/gcc/i486-wrs-vxworks/4.6.4/../../../../i486-wrs-vxworks/include/yvals.h:4:24: fatal error: yvals.h: No such file or directory

如果我进去看看/usr/local/i486-wrs-vxworks/include/yvals.h,这就是我所看到的:

/* yvals.h values header for conforming compilers on various systems */
#if (defined(__cplusplus) && defined(__GNUC__))
/* GCC C++ has it's own yvals.h */
#include_next <yvals.h>
#else /* __cplusplus && __GNUC__ */
#ifndef _YVALS
#define _YVALS
#ifdef _NO_WINDRIVER_MODIFICATIONS
#include <stdarg.h>
#endif
...

似乎还有另一个yvals.h需要包括在内,但我在任何地方都找不到。我只是未能正确构建 gcc,还是有办法解决这个问题?

4

2 回答 2

1

您使用的是哪个版本的 VxWorks?

我有一个模糊的回忆,在过去升级 VxWorks 版本时,yvals.h 中有一个语法错误,我需要解决这个问题,并在后续版本中修复。

此外,您可以从 WindRiver 中获得预构建的 gcc 交叉编译器。只需使用您的许可证号登录 windriver.com/support,然后前往“下载”以获取您的产品版本。

于 2013-11-11T18:39:49.693 回答
0

我自己经历了最近的交叉编译噩梦(与 VxWorks 无关),除了 yvals.h,我对 stddef.h 感到悲伤。问题原来是我需要指定系统头文件的包含路径。

以下是我解决错误消息所采取的步骤。随意修改。

创建一个文件 foo.c

#include <stddef.h>   /* The problem header file (yvals.h for you?) */

int main (void) {
    return 0;
}

用你选择的编译器编译它

$(CC) foo.c -E

注意它使用的包含路径,并将它们设置为您的系统头文件列表,使用

-isystem <include path>

选项。

希望这可以帮助。

于 2013-01-22T21:30:58.697 回答