【问题标题】:GCC cross-compiler for VxWorks can't compile C++VxWorks 的 GCC 交叉编译器无法编译 C++
【发布时间】:2013-01-22 17:49:27
【问题描述】:

我正在尝试移植一个 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,还是有办法解决这个问题?

【问题讨论】:

  • 你试过i486-wrs-vxworks-g++吗?
  • @MatsPetersson 是的,它给出了同样的错误。
  • /usr/local/i486-wrs-vxworks/include/yvals.h 中是否还有另一个包含yvals.h - 通常这些系统文件稍后会包含另一个...不幸的是,我不知道您问题的答案,所以我只能引导您沿着我要调查的道路前进。
  • /usr/local/i486-wrs-vxworks/include/yvals.h 中有一行#include_next &lt;yvals.h&gt; 表明在某处应该有另一个yvals.h...不幸的是,据我所知,它实际上并不存在。运行find / -name yvals.h 只会返回我已经知道的yvals.h
  • 所以,这就是它出错的“yvals.h”——我不完全确定它应该包含什么。就像一个黑客一样,你有没有试过只注释掉那一行(#include_next yvals)?

标签: c++ gcc cross-compiling vxworks


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

    我自己经历了最近的交叉编译噩梦(与 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>
    

    选项。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-05
      • 2017-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多