# g++ library version dependence



## applebee (Jan 14, 2009)

Hi:

I produced an executable and a dynamic library using g++
on an older FreeBSD, and found that it is linked against
an older version of "/usr/lib/libstdc++.so"
So it doesn't run on newer FreeBSD unless the newer FreeBSD installs the compat libraries.

Since I'm not using any advanced features, can I compile my program in such a way that it is not
picky about which version of libstdc++ it uses?

(Similar to how binaries on Mac OS X works with any library >= some version number)

Thank you!


----------



## LordGodfrey (Feb 2, 2009)

I can't say that this will work on FreeBSD, but on other Unix (Solaris, SCO) systems I've been forced to release an application as a staticly linked executable in order to do what you're talking about. Making it a single static executable means that it has everything it needs to run and is not dependent upon the machine having the appropriate dynamic libraries.

I haven't actually tried this on FreeBSD so can't say it will work for certain but it just might. From memory the compiler flag is something like -Bstatic.

If you need to have the dynamic library and don't want to or can't recompile your application on the later version of FreeBSD then I have nothing else to offer.


----------



## trev (Feb 2, 2009)

LordGodfrey said:
			
		

> If you need to have the dynamic library and don't want to or can't recompile your application on the later version of FreeBSD then I have nothing else to offer.



I've been known to edit the binary executable with vi to change the dynamic library to the correct version on the "new" system. This may not always work, but it is a lifesaver when you don't have the source code.


----------



## soaringhawkzf (Feb 3, 2009)

One solution(maybe) is to copy DLLs you used to program space just like under windows, then add the lib dir into LD_LIBRARY_PATH in runtime.
    I'm trying this way, just for testing.


----------

