简体   繁体   English

用于VxWorks的GCC交叉编译器无法编译C ++

[英]GCC cross-compiler for VxWorks can't compile C++

I'm trying to port a Linux library to run on VxWorks. 我正在尝试移植Linux库以在VxWorks上运行。 I have successfully built binutils and gcc to target i486-wrs-vxworks and I can successfully build a simple C program. 我已经成功构建了binutils和gcc来针对i486-wrs-vxworks,并且我可以成功构建一个简单的C程序。 However, when I try to compile C++, things break. 但是,当我尝试编译C ++时,事情中断了。

I have a simple Hello World program: 我有一个简单的Hello World程序:

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

To build it, I call: 要构建它,我称:

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

This always fails with the message: 这总是失败,并显示以下消息:

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

If I go look inside /usr/local/i486-wrs-vxworks/include/yvals.h , this is what I see: 如果我去看看/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
...

It appears that there is another yvals.h that needs to be included, but I can't find it anywhere. 似乎还需要包含另一个yvals.h ,但我在任何地方都找不到它。 Did I just fail at building gcc correctly, or is there a way to fix this? 我只是无法正确构建gcc,还是有办法解决?

Which version of VxWorks are you using for this? 您正在使用哪个版本的VxWorks?

I have a fuzzy recollection that when upgrading VxWorks versions in the past there was a syntax error in yvals.h that was I needed to work around and it was fixed in a subsequent version. 我有一个模糊的回忆,过去升级VxWorks版本时,需要解决yvals.h中的语法错误,该错误已在后续版本中修复。

Also, you can get the gcc cross compiler pre-built from WindRiver. 此外,您还可以从WindRiver中预先构建gcc交叉编译器。 Just login to windriver.com/support with your licence number and head to "Downloads" for your product version. 只需使用您的许可证号登录windriver.com/support,然后转到产品版本的“下载”即可。

I went through a recent cross compiling nightmare myself (not VxWorks related) except that instead of yvals.h, I was having grief with stddef.h. 我本人经历了最近一次交叉编译的噩梦(与VxWorks没有关系),只是我不是yvals.h,而是对stddef.h感到悲伤。 The problem turned out to be that I needed to specify the include paths for the system header files. 原来是我需要为系统头文件指定包含路径。

Here are the steps it took me to solve my error messages. 这是解决我的错误消息所采取的步骤。 Feel free to modify as appropriate. 随时进行适当的修改。

Create a file foo.c 创建一个文件foo.c

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

int main (void) {
    return 0;
}

Compile it with your compiler of choice 使用您选择的编译器进行编译

$(CC) foo.c -E

Note the include paths it uses and set them as your system header file list using the 注意它使用的包含路径,并使用以下路径将它们设置为系统头文件列表

-isystem <include path>

option. 选项。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM