how to use libstdc++.so.5 instead of libstdc++.so.6

  • Thread starter Alexander Dong Back Kim
  • Start date
A

Alexander Dong Back Kim

Dear all members,

First of all, I apologize I posted such a topic which is not purely
related with this group. The reason why I posted this is I hope some
of members this group knows about g++ and they have better idea about
my problem so please forgive my post.

I have this problem that development machine's default C++ library is
libstdc++.so.6. of course the OS is linux. However, the target machine
has libstdc++.so.5 so I copied the library file to dev machine.

Therefore, the dev machine has both version 5 and 6 of libstdc++
whereas the target machine has only version 5. I wrote and tested the
following application (not really an application) on the target
machine.

#include <iostream>
using namespace std;
int main() { cout << "hello" << endl; return 0; }

I compile the code with...

target $ g++ main.cpp

It, of course, produces "a.out". I did "ldd" to see what shared (or
dynamic) library the application links and the result was...

libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x00c25000)
libm.so.6 => /lib/tls/libm.so.6 (0x00951000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x006af000)
libc.so.6 => /lib/tls/libc.so.6 (0x0026c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00a42000)

Now I compiled the same application on the dev machine and did the
same command and the result is...

libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x005e8000)
libm.so.6 => /lib/tls/libm.so.6 (0x00372000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00555000)
libc.so.6 => /lib/tls/libc.so.6 (0x0023e000)
/lib/ld-linux.so.2 (0x00224000)

If I run the application, which was compiled on the dev machine, on
the target machine it says an error message...

../a.out: error while loading shared libraries: libstdc++.so.6: cannot
open shared object file: No such file or directory

This totally makes sense because the target machine doesn't have the
library "libstdc++.so.6". I did "ldd" and it shows more specific
reason.

libstdc++.so.6 => not found
libm.so.6 => /lib/tls/libm.so.6 (0x0079b000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00689000)
libc.so.6 => /lib/tls/libc.so.6 (0x00111000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x0046c000)

Now, I start falling in a panic because I have so many questions about
next step. I simply thought I might be able to copy the lib file
"libstdc++.so.6" from dev machine to target machine. However, I'm
wornding whether this is right thing to do. Is this problem that
simple? Would it cause some weird problems when a application needs to
use such thing like RTTI or exception handling? Because of these many
doubt, I slightly think about another way of doing this. What about
using "libstdc++.so.5" when I compile the application on the dev
machine?

Now. How can I do this? I have no idea how I can force g++ choose
libstdc++.so.5 instead of libstdc++.so.6? Moreover, I'm also worrying
about whether it is right thing...

or is whole my idea just crap? Please give me any suggestion or idea
before I knock the door of hell...

regards,
Alex Kim
 
A

anon

Alexander Dong Back Kim wrote:
[snip]
Now, I start falling in a panic because I have so many questions about
next step. I simply thought I might be able to copy the lib file
"libstdc++.so.6" from dev machine to target machine. However, I'm
wornding whether this is right thing to do. Is this problem that
simple? Would it cause some weird problems when a application needs to
use such thing like RTTI or exception handling? Because of these many
doubt, I slightly think about another way of doing this. What about
using "libstdc++.so.5" when I compile the application on the dev
machine?

Search for cross-compiler. You'll have to build one for your target
machine. This might help:
http://www.linuxfromscratch.org/lfs/read.html
Take a look at the chapter 5 how to build the cross compiler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top