Re: Template wrapper link query
On Jun 4, 8:52 pm, Paavo Helde <pa...@nospam.please.ee> wrote:
James Kanze <james.ka...@gmail.com> kirjutas:
On Jun 3, 8:50 pm, Paavo Helde <pa...@nospam.please.ee> wrote:
PGK <graham.k...@gmail.com> kirjutas:
I'd like to wrap a series of "C" library functions using
instantiated templates. I'd also like to have this interface
in a header file, but not require the user to link to the
"C" library.
Microsoft Visual C++ has #pragma comment(linker, ...) which
can be used for linking in the needed libraries whenever the
library headers are included. This seems like a feature you
are looking for. However, this is an implementation-specific
extension and thus off-topic here. I don't know if other
compilers provide something similar.
I don't think they do, but I don't think that solves his
problem, either. All the pragma does is free the client from
having to specify the name of the library when linking. The
library still must be present on the system, somewhere where the
compiler knows to look (a directory specified by /LIBPATH, or
the %LIB% environment variable), and the library will still be
linked into the final executable.
We are guessing what exactly OP wanted. In my mind, to expect
to benefit from the library without actually using it is a bit
unrealistic,
But we often have posters asking to do unrealistic things. Just
because it is unrealistic doesn't mean that that's not what he
meant.
so I assumed that OP just wants to remove the burden of
explicit linking from the library users. And this wish is not
so improper; when I include library headers, then I definitely
want to link against that library, so why should I tell this
separately?
If the libraries are installed in a common directory there is
no problem.
If different libraries are installed in the same directory, you
have real problems in managing things. Directories are there
precisely to keep these things separate.
In our Windows build system this mechanism is used for tens of
projects with no problems.
How do you manage which libraries are present, and which aren't?
How do you remove a library, being sure that all files in the
library are removed, and no other files?
Classically, under Unix, the solution was simple: each library
was put in its own, separate directory, and "rm -r libraryRoot"
removed it completely, with no risk of removing anything else.
of course, this typically meant that you needed two path
commands in the command line, a -IlibraryRoot/include and a
-LlibraryRoot/lib, plus an additional -lrary to specify the
library, but in the end, the client programmer does have to know
(or should know) that he's using the library.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34