如何使用另一组库进行编译。在i686 Fedora 13计算机上编译时,一切正常。但是,当我通过U盘获取可执行文件并尝试在另一台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库(这不应该是自动的吗)? 我在互联网上搜索了一些文章,有些文章说我缺少crt0.o文件,但是我在i386目录树中找不到这个文件。