Solved

the easiest way to build a dll file

Posted on 2002-07-03
11
192 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
Comment Utility
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
Comment Utility
>>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
Comment Utility
Exactly - VC6 will do the work for you
Jim
0
 
LVL 32

Expert Comment

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

Expert Comment

by:venkaiah
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 3

Expert Comment

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

Expert Comment

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

Expert Comment

by:jimbucci
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now