gpt4 book ai didi

c++ - 与另一个库交叉编译

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:36:19 25 4
gpt4 key购买 nike

如何使用另一组库进行编译。当我在 i686 Fedora 13 计算机上编译时,它工作正常。然而,当我获取可执行文件(通过拇指驱动器)并尝试在另一台 i386 机器上运行它时,我收到以下错误消息。

/usr/lib/libstdc++.so.6: version ‘GLIBCXX_3.4.9’ not found (required by ./Recorder)

好的,所以我必须使用 i386 库进行编译以使其兼容。然而,i368 机器没有编译器。所以我必须找到一种使用 i386 机器库进行交叉编译的方法。因此,我将所有 i386 目录树复制到 i686 机器中,并尝试使用 -nostdlib 并将所有库指向使用 i386,我整天都在使用设置,却一无所获。

我继续尝试制作一个小程序作为测试,看看是否可以先交叉编译。仍然没有运气。

/// \file main.cpp
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <iostream>
int main()
{
std::cout << "Testing!" << std::endl;
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
printf("POSIX Thread Priority Scheduling supported\n");
#else
#warning "POSIX Thread Priority Scheduling NOT supported."
#endif
#ifdef _POSIX_THREAD_PRIO_PROTECT
printf("POSIX Thread Priority Ceiling supported");
#else
#warning "POSIX Thread Priority Ceiling NOT supported"
#endif
#ifdef _POSIX_THREAD_PRIO_INHERIT
printf("POSIX Thread Priority Ceiling supported");
#else
#warning "POSIX Thread Priority Ceiling NOT supported"
#endif
return 0;
}

我用这个命令编译程序。

g++ -O3 -pedantic -Wextra -Wall -g -c /home/dmiller3/Experiments/Test2/main.cpp -o obj/Debug/main.o

链接时出现错误。

g++ -L../../TargetLibraries/cw_1901-glibc_std-standard-dist/lib  -o bin/Debug/Test2 obj/Debug/main.o   -nostdlib ../../TargetLibraries/cw_1901-glibc_std-standard-dist/lib/libpthread-2.5.so ../../TargetLibraries/cw_1901-glibc_std-standard-dist/lib/libc-2.5.so 
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to

00000000080482a0 obj/Debug/main.o: In function __static_initialization_and_destruction_0':
/usr/lib/gcc/i686-redhat-linux/4.4.4/../../../../include/c++/4.4.4/iostream:72:
undefined reference to
std::ios_base::Init::Init()' ...Lot more errors...

我们如何使用另一个库进行编译?为什么我必须明确指向 libc 库(这不应该是自动的)?我在 Internet 上进行了一些搜索,有些文章指出我缺少一个 crt0.o 文件,但是我在 i386 目录树中找不到这个文件。

最佳答案

/usr/lib/libstdc++.so.6: version ‘GLIBCXX_3.4.9’ not found (required by ./Recorder)

您尝试运行的机器上的 libstdc++ 比您编译的机器旧,这就是它提示的原因

关于c++ - 与另一个库交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3721807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com