缺少包括“bits/c++config.h";在 Ubuntu 中在 32 位上交叉编译 64 位程序时 [英] Missing include "bits/c++config.h" when cross compiling 64 bit program on 32 bit in Ubuntu

查看:38
本文介绍了缺少包括“bits/c++config.h";在 Ubuntu 中在 32 位上交叉编译 64 位程序时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 32 位版本的 Ubuntu 10.10 并尝试交叉编译到 64 位目标.根据我的研究,我已经安装了 g++-multilib 包.

I am running the 32bit version of Ubuntu 10.10 and trying to cross compile to a 64 bit target. Based on my research, I have installed the g++-multilib package.

该程序是一个非常简单的hello world:

The program is a very simple hello world:

#include <iostream>

int main( int argc, char** argv )
{
  std::cout << "hello world" << std::endl;
  return 0;
}

编译:

g++ -m64 main.cpp

错误:

In file included from main.cpp:1:
/usr/include/c++/4.4/iostream:39: fatal error: bits/c++config.h: No such file or directory
compilation terminated.

我找到了一个 c++config.h 文件,但它们位于 i486-linux-gnui686-linux-gnu 下> /usr/include/c++/4.4/目录下/usr/include/c++/bits中没有c++config.h>.

I have found a c++config.h file but they reside under the i486-linux-gnu and i686-linux-gnu directories in /usr/include/c++/4.4/ There is not c++config.h in /usr/include/c++/bits.

对我缺少的东西有什么想法吗?在没有 -m64 标志的情况下编译工作正常(a.out 已创建并正确运行).

Any ideas on what I am missing? Compiling without the -m64 flag works fine (a.out is created and runs correctly).

编辑 感谢@nightcracker 的提示,我对 32 位和 64 位系统上的包含结构进行了更多调查.我添加了一个 答案 暂时修复"了问题,但我认为它会在下次更新时中断.基本上,我缺少一个名为 /usr/include/c++/4.4/i686-linux-gnu/64 的目录,该目录应该包含一个名为 bits 的子目录,该子目录缺少包含文件.知道哪个包应该处理这个问题吗?

Edit Thanks to the hint from @nightcracker, I did a little more investigation into the include structure on the 32 and 64 bit systems. I have added an answer below that "fixes" the problem temporarily but I think it will break on the next update. Basically, I am missing a directory called /usr/include/c++/4.4/i686-linux-gnu/64 that should contain a subdirectory called bits that has the missing include file. Any idea what package should be taking care of this?

推荐答案

添加此答案的部分原因是它解决了我遇到的相同问题,因此我可以自己将此问题添加为书签.

Adding this answer partially because it fixed my problem of the same issue and so I can bookmark this question myself.

我能够通过执行以下操作来修复它:

I was able to fix it by doing the following:

sudo apt-get install gcc-multilib g++-multilib

如果您安装了一个默认不附带的 gcc/g++ 版本(例如 lucid 上的 g++-4.8) 您还需要匹配版本:

If you've installed a version of gcc / g++ that doesn't ship by default (such as g++-4.8 on lucid) you'll want to match the version as well:

sudo apt-get install gcc-4.8-multilib g++-4.8-multilib

这篇关于缺少包括“bits/c++config.h";在 Ubuntu 中在 32 位上交叉编译 64 位程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆