Solved

the easiest way to build a dll file

Posted on 2002-07-03
11
199 Views
Last Modified: 2010-04-01
IS there an easy way to build an DLL file??  Where can I find the infomation to build a DLL file?  I am using msvc++ 6.0.
0
Comment
Question by:lcrogers
11 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 100 total points
ID: 7127975
From the M$ knowledgebase:


   /* DLL Sample: TESTDLL.CPP
   /* Compile options needed: /D"_X86" /MT TESTDLL.CPP /link
   /*                  /DLL /OUT:testdll.dll /implib:testdll.lib
   */

   #include <stdio.h>

   class DLLClass
       {
       public:
        // exported member function
        __declspec( dllexport ) void functionA( void ) {
            printf("\nIn Function A of the exported function");
        }
       };

   // exported class
   class __declspec( dllexport) ExportDLLClass
       {
       public:
        void functionB(void) {
           printf("\nIn Function B of the exported class");
        }
       };

   // exported instance of the DLLClass
   __declspec(dllexport) DLLClass test;


   /* Source that calls the DLL Sample: CALLDLL.CPP
   /* Compile options needed: /D"_X86" /D"_CONSOLE" /ML CALLDLL.CPP
   /*                  TESTDLL.LIB
   */

   #include <stdio.h>

   class DLLClass
       {
       public:
        // imported member function
        __declspec( dllimport ) void functionA( void );
       };

   class __declspec( dllimport) ExportDLLClass
       {
       public:
        void functionB(void);
       };

   __declspec( dllimport ) DLLClass test;

   void main(void)
   {
      ExportDLLClass TestClass;

      test.functionA();
      TestClass.functionB();
   }




Good luck!!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7128792
>>IS there an easy way to build an DLL file??

I think you want to create a DLL file.   The easiest way to do that is to use the VC++ AppWizard.  Just choose File/New, Projects then select either
   MFC AppWizard (DLL)
or
   Win32 Dynamic Link Library.

Depending upon options that you select in teh Wizard, it will create a skeleton of a DLL... all you need to do is add some code and (optionally) some resources.

-- Dan
0
 
LVL 3

Expert Comment

by:jimbucci
ID: 7129507
Exactly - VC6 will do the work for you
Jim
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:jhance
ID: 7129667
Of course, everybody knows that "Real Programmers" never use Wizards!!  ;-)
0
 
LVL 2

Expert Comment

by:venkaiah
ID: 7130175
i am giving a skelton program try it out.
Take a project option as win32 dynamic link library
name of the project is DLLTEST
in that add sum.h and sum.cpp
write the following code in sum.h
extern "C" __declspec(dllexport)
int sum(int x,int y);
write the following code in sum.cpp
#include "sum.h"
int sum(int x,int y)
{
return x+y;
}
build it.now it generates DLLTEST.lib and DLLTEST.dll

for testing the above dll write one console application i meant client for this
take new IDE.select project option win32 console application
add client.cpp
write the following code in client.cpp

#include <iostream.h>

extern "C" __declspec(dllimport)
int sum(int x,int y);

void main()
{
cout<<sum(3,5);
}

copy the dll in to your client debug directory.and specify the lib name in project->settings->link tab->object/library modules section
and set the path for lib in tools->options->directories->library files

i think this will helps u.
0
 
LVL 3

Expert Comment

by:jimbucci
ID: 7134858
Yeah, you could always do it in assembler.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7135572
Probably better to just use hexadecimal opcodes directly.  Assembly language is for wimps.
0
 
LVL 3

Expert Comment

by:jimbucci
ID: 7137344
opcodes - my 19 month old can do opcodes.  Get some punchcards and do it in binary...  If you're a REAL programmer.  
But if you want to save time - the wizards do all the work.
Thank you and good night.
JB
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7139078
Binary?  Back when I started we didn't have ones and zeros.  We had to work with only zeros AND WE LIKED IT.
<bows>
0
 
LVL 11

Expert Comment

by:griessh
ID: 7353427
Dear

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "DrDelphi"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7419750
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Socket Programming (Unix) 8 153
How to convert Structure to vector of byte and vice versa 5 31
learn programming 8 68
Need some help with design 15 15
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question