缺少包含“bits/c”“config.h”在Ubuntu 32位上交叉编译64位程序时
我正在运行 32 位版本的 Ubuntu 10.10 并尝试交叉编译到 64 位目标。根据我的研究,我安装了 g++-multilib 软件包。
该程序是一个非常简单的 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-gnu
和 < /usr/include/c++/4.4/
中的 code>i686-linux-gnu 目录 / 中没有
。c++config.h
usr/include/c++/bits
对我所缺少的有什么想法吗?不使用 -m64
标志进行编译可以正常工作(a.out 已创建并正确运行)。
编辑 感谢 @nightcracker 的提示,我对 32 位和 64 位系统上的包含结构进行了更多调查。我添加了 下面的答案暂时“解决”了问题,但我认为它会在下次更新时崩溃。基本上,我缺少一个名为 /usr/include/c++/4.4/i686-linux-gnu/64
的目录,该目录应包含一个名为 bits
的子目录,该子目录缺少包含内容文件。知道应该用什么包来处理这个问题吗?
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.
The program is a very simple hello world:
#include <iostream>
int main( int argc, char** argv )
{
std::cout << "hello world" << std::endl;
return 0;
}
Compile:
g++ -m64 main.cpp
Error:
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.
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
.
Any ideas on what I am missing? Compiling without the -m64
flag works fine (a.out is created and runs correctly).
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
添加此答案的部分原因是它解决了我同一问题的问题,因此我可以自己为这个问题添加书签。
我可以通过执行以下操作来修复它:
如果您安装了默认情况下不提供的
gcc
/g++
版本(例如g++ -4.8
on lucid)你也想匹配版本: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:
If you've installed a version of
gcc
/g++
that doesn't ship by default (such asg++-4.8
on lucid) you'll want to match the version as well:您是否尝试添加 -I/usr/include/c++/4.4/i486-linux-gnu 或
-I/usr/include/c++/4.4/i686-linux-gnu
?Did you try adding
-I/usr/include/c++/4.4/i486-linux-gnu
or-I/usr/include/c++/4.4/i686-linux-gnu
?在 RHEL 6.2 (x86_64) 中编译时,我安装了 32 位和 64 位 libstdc++-dev 软件包,但遇到了“c++config.h 没有这样的文件或目录”问题。
解决方案:
目录
/usr/include/c++/4.4.6/x86_64-redhat-linux
丢失。我执行了以下操作:
我现在可以在 64 位操作系统上编译 32 位二进制文件。
While compiling in RHEL 6.2 (x86_64), I installed both 32bit and 64bit libstdc++-dev packages, but I had the "c++config.h no such file or directory" problem.
Resolution:
The directory
/usr/include/c++/4.4.6/x86_64-redhat-linux
was missing.I did the following:
I'm now able to compile 32bit binaries on a 64bit OS.
似乎是 gcc 那个包中的拼写错误。解决办法:
Seems to be a typo error in that package of gcc. The solution:
基本上它用于 HeapOverflows 或其他反转类型问题,即如果您想将 64 位 ELF 更改为 32 位 ELF 并且在转换时显示错误。
您只需运行
将更新您的库的 命令
套餐升级:
类似于此将显示在您的终端上
Basically It is used in HeapOverflows or other reversing type Problems i.e. If you want to change a 64 bit ELF to 32 bit ELF and it is showing error while converting.
You can simply run the commands
which will update your libraries
Packages upgraded:
similar to this will be shown to your terminal
在我的 64 位系统上,我注意到存在以下目录:
然后,在为 64 位交叉编译设置的 32 位系统上,应该有一个相应的目录,例如:
我仔细检查,该目录不存在。使用 verbose 参数运行
g++
表明编译器实际上是在这个位置寻找某些东西:关于
ignoring nonexistent directory
的错误就是线索。不幸的是,我仍然不知道需要安装什么软件包才能显示此目录,因此我只是从以下位置复制了/usr/include/c++/4.4/x86_64-linux-gnu/bits
目录我的 64 位机器到我的 32 机器上的/usr/include/c++/4.4/i686-linux-gnu/64/bits
。现在仅使用
-m64
即可正常编译。主要缺点是,这仍然不是正确的处理方式,我猜测下次更新管理器安装并更新到 g++ 时,事情可能会中断。On my 64 bit system I noticed that the following directory existed:
It would then make sense that on my 32 bit system that had been setup for 64bit cross compiling there should be a corresponding directory like:
I double checked and this directory did not exist. Running
g++
with the verbose parameter showed that the compiler was actually looking for something in this location:The error regarding the
ignoring nonexistent directory
was the clue. Unfortunately, I still don't know what package I need to install to have this directory show up so I just copied the/usr/include/c++/4.4/x86_64-linux-gnu/bits
directory from my 64 bit machine to/usr/include/c++/4.4/i686-linux-gnu/64/bits
on my 32 machine.Now compiling with just the
-m64
works correctly. The major drawback is that this is still not the correct way to do things and I am guessing the next time Update Manager installs and update to g++ things may break.此错误在“gcc-4.6”中已修复。
https://bugs.launchpad.net/ubuntu/+source/ gcc-4.5/+bug/793411
This bug is fixed in "gcc-4.6".
https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/793411
根据我的经验,
sudo apt-get install gcc-multilib g++-multilib
有帮助。但我的另一个问题是我忘记清理目录,所以我仍然遇到相同的错误。第一次使用clang或者cmake。所以我只要删除原来的目录并重新编译就可以了。希望它能帮助像我这样的人。From my experience,
sudo apt-get install gcc-multilib g++-multilib
helps. But my another issue is that I FORGET to clean the directory so I still get the same error. It is the first time to use clang or cmake. So I just delete my original directory and re-compile and it works. Hope it helps someone like me.在 x86 机器上针对arm32进行交叉编译时遇到了同样的问题,如果您要针对arm进行交叉编译,请确保您已经安装了最新的libstdc++ pkg。
然后您可能会遇到另一个标头错误,即找不到“asm/errno.h”文件。只需为此安装 gcc-multilib 即可。
Ran into the same problem while cross-compiling on x86 machine for arm32, if you are cross-compiling then for arm then make sure you have installed the latest libstdc++ pkg.
Then you may run into another header error which is 'asm/errno.h' file not found. Just install gcc-multilib for this.
就我而言,这只是一个路径问题。我减少了源文件的路径长度并且它起作用了......
In my case, it only has been a path issue. I reduced the path length of my source files and it worked...