I'm facing an issue in which my program is using a custom library (say, libxyz.so) which is compiled using libstdc++.so.5 and the system I'm using this library to create an executable from my program, has libstdc++so.6 as well as libstdc++.so.5; both available under /usr/lib directory.
There are multiple compilers available with the system (i.e gcc, g++34 and g++ version 4.*, IBM xlc).
When I compile my program, the resultant binary has to link libxyz.so (which has libstdc++.so.5 already) and based on further symbols need, it has to use libstdc++.so, but it by default links with libstdc++.so.6 and these two versions of libstdc++ gets its way into my executable.
This clearly shows up the cross links when done ldd on my executable. The program crashes when run. Because some classes are not compatible in libstdc++.so between versions 5 and 6.
Being C++ program, still I compiled and linked with gcc itself which is by default linking only with libstdc++.so.5 but had to use -fno-use-cxa_exception_ptr as flag to suppress the undefined reference issue on exception handling code. This made my binary having uniform links with libstdc++.so.5 through out and the program runs well. But this is just a work around and not an acceptable solution.
Is there a way, in which we can make g++ (or even g++34) to link explicitly with a particular library version overriding the default behavior to link with the latest version?
In that case I would prefer to link with libstdc++.so.5 through out.
Thanks a lot in advance for your suggestions / insight and for your precious time of course.
Regards,
PraveenK
---------- Post updated at 12:25 AM ---------- Previous update was at 12:05 AM ----------
It would also be great, if you suggest on editing the gcc/g++ compile specs. However that again is not a very open option if this is not an user account specific changes. Although I have the root access but would not be allowed to make system configuration changes.
Last edited by Praveen_218; 02-18-2014 at 02:50 PM..
Reason: Typo errors.
I'm confused. Is there no way to link your library code on each platform? That way it will always run wherever it is ported to. It is not clear to me if this is what you are asking.
You seem to want to be able to link your code where ever it resides. You have two choices: link statically on the home machine, or compile to object code - ex: libfoo.a, on the home machine, then link a new PIC code library on each platform. Assuming your code links correctly against various installation of c++.
Static linking kind of defeats the purpose of a library. But it will work.
You cannot depend on version libstsdc++5 or 6 or whatever being available when you port your code. Lugging dynamic code from box to box is not always feasible. As you found out.
This User Gave Thanks to jim mcnamara For This Post:
Hi Jim,
Thanks for your response to my query.
No, I don't have the option to re-compile the library (say libxyz.so) and this is a black box to me being a 3rd party library package already compiled for my platform. This library using an older version of libstdc++.so.5; however my platform currently has libstdc++.so.6 (as well as libstdc++.so.5 co-existing) and the g++ compiler by default uses libstdc++.so.6 to link any code compiled on my platform (however gcc picks up libstdc++.so.5 by default).
Hence compiling a program which also uses libxyz.so through g++ is creating an undesired scenario by linking to some function calls using libstdc++.so.6 (by default) and some function calls residing into the library libxyz.so also is linked to my program as their API is called but those API's function definition has already linked to libstdc++.so.5
Hence I get an executable which has function calls linking to two versions of libstdc++.so. This creates problem while execution and dumps code.
All I need is a way to override the library selection behavior by the compiler/linker so that I can choose to link to a particular version of my choice at the link time.
I essentially want to link all my programs to libstdc++.so.5 and NOT with libstdc++.so.6
I tried "ldconfig" utility to change behavior by following (as a root):
The file "ldconf.conf" thus produced had libstdc++.so.6 listed just prior to libstdc++.so.5; so I swapped their positions and did the following:
Have you tired putting libstdc++.so.5 in a different place and using LD_LIBRARY_PATH to point to that location?
Yes already tried. Even I created a soft link inside my present working directory to point to libstdc++.so.5; didn't work.
Did like this:
I also did
Just to understand how g++ is finding libraries by default and found it looks to certain number of pre-defined directories one by one on a decreasing priority (including reaching a level to look inside /usr/lib folder).
But why g++ is choosing version 6 when the same /usr/lib folder has version 5 where as gcc chooses version 5 when the same directory has higher version 6 available to it.
There must be somewhere the information g++ is driving out to select a particular version over other, when multiple available.
LD_LIBRARY_PATH doesn't work that way... Give it an absolute path, and only one path.
Sure Corona, I'll try his again tomorrow morning and update you.
---------- Post updated at 11:34 AM ---------- Previous update was at 12:03 AM ----------
Hi Corona,
Didn't work for me or did I do some mistakes? Here is the combined output for a sample program compilation:
I also ran strace over compilation and the strace log files are attached for your reference. Like:
Also tried running ldconfig utility, like:
Created a copy of file ldLib.log as ldLib.log.2 and edited the file ldLib.log.2 to swap positions of libstdc++.so.6 and libstdc++.so.5 and ran the config utility again, like:
Got errors logged into file ldconfig-f.log for reference and is attached herewith this post.
Here are few other information, which might be of help:
Lo guys, I've just started a new department in work and I'm going to be using HP-UX with Vi. The problem is I'm completely new to UNIX, I'm currently learning at work but I only have limited amounts of time on our dev systems. Is it possible to get a free/educational version any where? I don't... (4 Replies)
It took me a while, but I found the right libsdc++ for the current free vnc 4.1.3, deep in this: http://mirrors.develooper.com/hpux/gcc-3.3.2-11.00.sd.bz
Merijn's HP-UX software Download Section for ITRC members is a rich source for old libraries.
So if you cannot find the right depot or... (0 Replies)
hi guys
I have to install a software that says have theses packages are required
Libaio.so.1
Libstdc++so.6
are these default packages for a Suse 11 installation for instance? or do I need to download them to avoid dependency issues
thanks a lot
---------- Post updated at 10:00 PM... (0 Replies)
Hi all,
I am working on Red Hat Enterprise Linux ES release 4 (Nahant) with kernel 2.6.9-5 and try to install one application but unable to install it.
When I am trying to install it,it is throwing the following error--
To resolve it,I installed gcc 4.0.0 and when I am trying to see gcc... (2 Replies)
hello everybody i am new on the AIX environment and i have faced an issue while running pstill it can't find ibstdc++.a (libstdc++.so.5) although i have the latest GCC and libstdc 4.0.0 i guess.
So to resolve the problem i have got an old versions that i want to install on AIX:
... (5 Replies)
I got my hands on a HP9000/380 and need a (really) old version of HP-UX, like 7 or 8.
Is there any vendor who sells older versions? I did a quick search here and checked the FAQ and HPs HP-UX site but couldn't find anything. :confused:
Any help is appreciated! (4 Replies)
Our development machines have libstdc++.so.5 and libstdc++.so.6.
When we build our native code, it uses libstdc++.so.6. Is there anyway I can force it to use libstdc++.so.5 instead ?
$ ldd try
/usr/lib/libcwait.so (0x00655000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6... (5 Replies)