views:

55

answers:

1

How to compile with another set of libraries. When I compile on i686 Fedora 13 computer, it works fine. However, when I take the executable (via thumbdrive) and try to run it on another i386 machine, I get the following error message.

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

Okay, so I have to compile using the i386 libraries so it's compatible. However, the i368 machine doesn't have a compiler. So I have to find a way to cross-compile with using the i386 machine libraries. So I copy all of i386 directory tree into the i686 machine and try to use -nostdlib and point all libraries to use the i386, and I've played with settings all day long and get no where.

I went ahead and tried to make a small program as a test and see if I could get it to cross compile first. Still no luck.

/// \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;
}

I compile the program with this command.

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

I get the error when linking.

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...

How do we compile with another library? Why do I have to explicity point to the libc library (shouldn't this be automatic)? I've done some searching on the internet, and some articles state that I'm missing a crt0.o file, however I can't find this file on the i386 directory tree.

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

The libstdc++ on the machine you are trying to run is older then the one you compile on, that is why it is complaining

Artyom
So how can I compile using older libstdc++, that is what I'm trying to accomplish. I can't find a way to point the compiler to use the older libstdc++.
Dennis Miller
@Dennis Miller You need to use older C++ compiler, usually you'll need something like g++-4.1 or even g++-3.4 depending on what is the system you are targeting to.
Artyom