Producing library files from D

Shriramana Sharma samjnaa at gmail.com
Fri May 31 04:26:54 PDT 2013


Hello. How do I make a library from D? I see the dmd --help output
give a -lib option but am not sure how to actually use it. Can I
produce a library and then just import it by its name? (This is an
offshoot of my previous query about the proprietary lib thing.)

And given that http://dlang.org/cpp_interface.html talks about
compiling a C++ file with a C++ compiler and a D file with a D
compiler and then linking the two together, do I understand something
like:

clang -c cpplib.cpp
dmd -c dprog.d
ld -o d-cpp-joint-venture cpplib.o dprog.o -lm

What do I do to create a sharedlib/staticlib which would have both C++
and D objfile components? Is it the regular:

ld -shared -o $(SHAREDLIB) $(OBJFILES) -lm

and

ar r $(STATICLIB) $(OBJFILES)
ranlib $(STATICLIB)

IOW, after dmd finishes compiling, it is just like any other object
file on my platform?

Thanks as ever for your patience!

-- 
Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा


More information about the Digitalmars-d-learn mailing list