How to link share libraries to binary if multiple versions available on system

Bvm 18
Bvm 18 used Ask the Experts™

  compiling xerces on solaris box.
  /usr/lib/sparcv9/ and /usr/lib/64 have libicu*54.  
  In another location, /icu_needs_to_build_with/libicu*44.
  Whenver I compile, it's always picking libicu*54 version. I do want to build xerces with libicu*44 libraries.
  Do we have any flags like LDFLAGS or xyz to configure specific version shared libs?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
evilrixSenior Software Engineer (Avast)

As far as I know, the only solution to this is to link to the specific static library you want to use directly.


g++ -o main main.cpp /path-to-lib/libicu*44.lib

Open in new window

Take a look at your makefile or cmake file to see how your library is referenced. Sometimes what is referenced is not a library but a link to a library. This approach is taken so that one makefile may be used without alteration on multiple platforms. If that is the case, then you can have your administrator change the link target if you are the only one using it, or if that specific library is the one that must be used on that platform.

 If you are permitted to change the link yourself, here are instructions:


Hi evilrix,

  These are all libicu*so.versionnumber.  How to specify to pick icu shared libraries from non-system paths.

evilrixSenior Software Engineer (Avast)

Link to the static stub library of the version you want to use (using either of the techniques above) and it should just pick the correct shared library version.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial