I have a library with both newer and older version
installed, their soname are libHELLO.so.1 and libHELLO.so.2.
Although the C standards talk about the standard library, the
implementation details are intentially left exceedingly vague --
to the point where the "library" could be an inherent part of
the compiler, or of the OS, or in source code form, rather than a
seperate file.
The C standards do not specify anything (that I can recall) about the
existance of other libraries -- only that there will be the ability to
link together the compilation of seperate files. I haven't reviewed the
wording for awhile, but my recollection is that a compiler that
accepted only source files and insisted that all those source files
be named on the (same) command line would be conforming -- i.e.,
intermediate object code and libraries are not required to exist.
When I use
gcc prog.c -o prog -lHELLO
the prog will use libHELLO.so.2 by default.
A simple question, how can I ask gcc to use
libHELLO.so.1 ?
As per the above discussion, that is a system and compiler dependant
matter that you may need to ask about in one of the gnu.* newsgroups.
In many implementations, you can link a specific version of a
library by naming the fuller name of the containing file. For
example,
gcc prog.c -o prog -LHELLO.so.1
or it might in your system be necessary to go as far as something like
gcc -o prog prog.c /usr/local/lib/libHELLO.so.1
If these don't work for you, ask in the gnu groups, specifying there
your operating system.