none
nmake: build DLL

    Question

  • Does anyone know the command in Makefiles to build DLLs using nmake? Also, are there any good references or books out there that tell you how to use nmake? Any wisdom shed here would be much appreciated.

    Thanks.
    Friday, March 07, 2008 2:19 AM

Answers

  • Hi,

     

    NMAKE builds the source files based on the commands contained in your make file.

    Thus, to produce a dll with NMAKE, just add the commands for building a DLL to the Makefile. Generally, we use cl command line to do this. For example, if you have a dll source file as:

    Code Snippet

    __declspec(dllexport) int __cdecl Add(int a, int b)

    {

       return a+b;

    }

     

     

    Assume you save it to “D:\Add.cpp”, then you can create a makefile as follows

     

    Code Snippet

    Add.dll:

     cl "D:\Add.cpp" /link /DLL /out:Add.dll

     

     

     

    And then produce the DLL through the NAMKE tool with above make file.

     

    This is just a sample; the Makefile is generally more complex.

    For detail information, you can refer to

    http://msdn2.microsoft.com/en-us/library/yz1tske6(VS.80).aspx

    http://msdn2.microsoft.com/en-us/library/dd9y37ha(VS.80).aspx

     

    Hope this helps!

     

    Wednesday, March 12, 2008 9:57 AM