?
Solved

the easiest way to build a dll file

Posted on 2002-07-03
11
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 400 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
Industry Leaders: 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

Technology Partners: 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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

718 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