Solved

the easiest way to build a dll file

Posted on 2002-07-03
11
200 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 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
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!

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

752 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