www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Producing library files from D

reply Shriramana Sharma <samjnaa gmail.com> writes:
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!

--=20
Shriramana Sharma =E0=AE=B6=E0=AF=8D=E0=AE=B0=E0=AF=80=E0=AE=B0=E0=AE=AE=E0=
=AE=A3=E0=AE=B6=E0=AE=B0=E0=AF=8D=E0=AE=AE=E0=AE=BE =E0=A4=B6=E0=A5=8D=E0=
=A4=B0=E0=A5=80=E0=A4=B0=E0=A4=AE=E0=A4=A3=E0=A4=B6=E0=A4=B0=E0=A5=8D=E0=A4=
=AE=E0=A4=BE
May 31 2013
parent "Regan Heath" <regan netmail.co.nz> writes:
On Fri, 31 May 2013 12:26:54 +0100, Shriramana Sharma <samjnaa gmail.com>  
wrote:

 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!
Have you seen this: http://dlang.org/dmd-linux.html#library R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
May 31 2013