www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - New pragma lib - better handling of dynamic libs

To my knowledge the current pragma(lib, "") in D only works for static 
libraries and therefore I would like to see a new pragma(lib, "") in D, 
similar to pragma(link, "") in dsss, with support for dynamic libraries. 
I want this because I would like to have better handling of dynamic 
libraries in D.

Now when you want to link to a dynamic library you either have to 
explicitly link with a compiler/linker flag or you have to use 
tango.sys.SharedLib or similar. The later adds some extra code that's 
not needed when linking explicitly. It feels like I'm doing the work 
twice, first creating the bindings and then loading the library so the 
bindings will work.

I basically want what dsss offers with pragma(link, ""). You just 
specify  the library name without file extension to support multiple 
platforms. For example: pragma(link, "library") will link on linux link 
to lib<library>.a (or lib<library>.so), on darwin lib<library>.a (or 
lib<library>.dylib) and on windows <library>.lib.

I would also like support for linking frameworks either with a 
pragma(framework, "") or preferable if possible using the same pragma 
described above.

I would like this in D1 also.

Feel free to correct me if I'm wrong with something above.

/Jacob Carlborg
Mar 20 2009