使用 32 位 g++在 AIX 上构建 64 位二进制文​​件

发布于 08-24 09:46 字数 3257 浏览 6 评论 0原文

我正在尝试使用 32 位 g++ 编译器从 C++ 代码构建 64 位二进制文​​件。 我在构建时遇到以下错误:

=> /usr/local/bin/g++ -shared -maix64 -fPIC -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bE:gcc_shr_lib.so.exp -o gcc_shr_lib.so gcc_shr_lib.o -L/usr/local/lib
ld: 0711-319 WARNING: Exported symbol not defined: gcc_whereAmI
ld: 0711-317 ERROR: Undefined symbol: typeinfo for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: __gxx_personality_v0
ld: 0711-317 ERROR: Undefined symbol: vtable for std::exception
ld: 0711-317 ERROR: Undefined symbol: vtable for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::Init()
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::~Init()
ld: 0711-317 ERROR: Undefined symbol: .operator new(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .operator delete(void*)
ld: 0711-317 ERROR: Undefined symbol: ._Unwind_Resume
ld: 0711-317 ERROR: Undefined symbol: .__cxa_get_exception_ptr
ld: 0711-317 ERROR: Undefined symbol: .__cxa_begin_catch
ld: 0711-317 ERROR: Undefined symbol: std::cout
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
ld: 0711-317 ERROR: Undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
ld: 0711-317 ERROR: Undefined symbol: .std::bad_alloc::~bad_alloc()
ld: 0711-317 ERROR: Undefined symbol: .__cxa_end_catch
ld: 0711-317 ERROR: Undefined symbol: .__register_frame_info_table
ld: 0711-317 ERROR: Undefined symbol: .__deregister_frame_info
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

看来我需要在我的构建系统上提供 64 位 libstdc++。有人可以提供一些线索来解决这个问题吗?

  1. 可以在 AIX 5.2 上使用 32 位 g++ 编译器构建 64 位二进制文​​件吗?

  2. 我应该从哪里获取 64 位 libstdc++?这个 64 位 libstdc++ 可以与 32 位 g++ 编译器一起使用吗?


非常感谢您的快速回复并指出问题。

以下是我正在使用的 GCC/G++ 版本:

=> gcc -v
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls
Thread model: aix
gcc version 4.1.1
[tsivaram@maroon /]
=> g++ -v
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls
Thread model: aix
gcc version 4.1.1

由于 gcc 和 g++ 是使用 --disable-aix64 配置/构建的,因此没有可用的 64 位 STD 库(例如:libstdc++)。

AIX version i am using:
=> uname -a
AIX maroon 2 5 000663FC4C00
[tsivaram@maroon /]
=> oslevel
5.2.0.0
[tsivaram@maroon /]
=> oslevel -r
5200-05

如何构建 64 位 libstdc++,它应该与 gcc/g++ 4.1.1 一起使用?

我是否需要在不使用 --disable-aix64 标志的情况下重建 GCC 和 G++?如果是,您能给我一个解释如何构建的链接吗?

我们不能只构建 libstdc++ 库(必需)吗?

I am trying to build a 64-bit binary from C++ code using 32-bit g++ compiler.
I am getting the following errors while building:

=> /usr/local/bin/g++ -shared -maix64 -fPIC -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bE:gcc_shr_lib.so.exp -o gcc_shr_lib.so gcc_shr_lib.o -L/usr/local/lib
ld: 0711-319 WARNING: Exported symbol not defined: gcc_whereAmI
ld: 0711-317 ERROR: Undefined symbol: typeinfo for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: __gxx_personality_v0
ld: 0711-317 ERROR: Undefined symbol: vtable for std::exception
ld: 0711-317 ERROR: Undefined symbol: vtable for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::Init()
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::~Init()
ld: 0711-317 ERROR: Undefined symbol: .operator new(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .operator delete(void*)
ld: 0711-317 ERROR: Undefined symbol: ._Unwind_Resume
ld: 0711-317 ERROR: Undefined symbol: .__cxa_get_exception_ptr
ld: 0711-317 ERROR: Undefined symbol: .__cxa_begin_catch
ld: 0711-317 ERROR: Undefined symbol: std::cout
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
ld: 0711-317 ERROR: Undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
ld: 0711-317 ERROR: Undefined symbol: .std::bad_alloc::~bad_alloc()
ld: 0711-317 ERROR: Undefined symbol: .__cxa_end_catch
ld: 0711-317 ERROR: Undefined symbol: .__register_frame_info_table
ld: 0711-317 ERROR: Undefined symbol: .__deregister_frame_info
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

It seems I need 64-bit libstdc++ available on my build system. Could someone please throw some light on to solve this?

  1. Is it OK to build 64-bit binaries using 32-bit g++ compiler on AIX 5.2?

  2. Where should I get 64-bit libstdc++? Will this 64 bit libstdc++ work with 32-bit g++ compiler?


Thanks a lot for your quick response and for pointing out the problem.

Following are the versions of GCC/G++ I am using:

=> gcc -v
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls
Thread model: aix
gcc version 4.1.1
[tsivaram@maroon /]
=> g++ -v
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls
Thread model: aix
gcc version 4.1.1

Since gcc and g++ are configured/built with --disable-aix64, there are no 64-bit STD libraries available (Ex: libstdc++).

AIX version i am using:
=> uname -a
AIX maroon 2 5 000663FC4C00
[tsivaram@maroon /]
=> oslevel
5.2.0.0
[tsivaram@maroon /]
=> oslevel -r
5200-05

How can I build 64-bit libstdc++, which should work with gcc/g++ 4.1.1?

Do I need to rebuild GCC and G++ without the --disable-aix64 flag? If yes, could you please point to me a link explaining how to build?

Can not we just build libstdc++ library (required)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓2024-08-31 09:46:25

您似乎正在构建一个共享库而不是可执行文件。

只要机器上有相关的 64 位库,无论您的 G++ 本身是 32 位还是 64 位二进制文​​件都没有关系 - 它应该能够生成 32 位和 64 位对象文件(以及共享库和可执行文件等)。

请注意,GCC(或 G++)故意使用与其他编译器不同的名称修改方案 - 因为它执行与其他编译器不同的各种操作(例如异常处理、类布局等)。您无法可靠地将使用本机 XLC 编译器编译的代码与使用 G++ 编译的代码链接起来。但是,您似乎并没有在这里这样做。

您应该在 /usr/local/lib 下查看以 64 位 C++ 库的方式找到的内容;您可能需要在命令行上提及正确的目录和共享库名称。或者,将“-v”标志添加到命令中并查看实际执行的内容。

你似乎只是缺少符号;您没有不匹配的 32 位与 64 位目标文件或库或其他任何内容。所以,你已经很接近了——只是还没有完全实现。

(AIX 5.2 仍然受支持吗?您难道不应该计划迁移到 5.3 或 6.1 吗?)

You seem to be building a shared library rather than an executable.

As long as the relevant 64-bit libraries are available on the machine, it should not matter whether your G++ is itself a 32-bit or a 64-bit binary - it should be able to generate both 32-bit and 64-bit object files (and shared libraries, and executables, etc).

Be aware that GCC (or G++) uses a different name-mangling scheme from other compilers quite deliberately - because it does various things (such as exception handling, class layouts and the like) differently from other compilers. You cannot reliably link code compiled with the native XLC compilers with code compiled with G++. However, you do not seem to be doing that here.

You should look under /usr/local/lib to see what you can find in the way of 64-bit C++ libraries; you may need to mention the right directory and shared library name on the command line. Alternatively, add the '-v' flag to the command and see what is actually being executed.

You seem to just have missing symbols; you don't have mismatched 32-bit vs 64-bit object files or libraries or whatever. So, you're close - just not quite there yet.

(Is AIX 5.2 still supported? Shouldn't you be planning to move to 5.3 or 6.1?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文