Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Creation of a DLL containing classes in BC 4.52

Posted on 1997-04-28
3
Medium Priority
?
404 Views
Last Modified: 2012-08-14
I am working on a large project for Windows 3.1 16 bits. With time, I have been forced to reduce my stack more and more up to the point I couldn't do it anymore. So now I HAVE to make a DLL. It's a first for me and I am having a little trouble with it. Here's what happens:

Borland ++ version 4.52

Project->New Project

- Target type :
Dynamic Library [.dll]

-Platform :
Windows 3.xx (16)

-Target model :
Large

-Standard library :
Class library
Runtime
Static

In the IDE projet I delete the files .DEF and the .RC

In dll.cpp :

class _MYCLASS MyClass0
{
  public:
  int MyInt;
  ...
};


_MYCLASS is defined with

#if defined(BUILD_MY_DLL)
  #define _MYCLASS __export
#elif defined(USES_MY_DLL)
  #define _MYCLASS __import
#else
  #define _MYCLASS
#endif

In the project options creating the DLL, I define "BUILD_MY_DLL" and USES_MY_DLL in the project using the DLL


C++ compile doesn't have any problem

If I compile too many classes while editing the link, an extra dialog box appears while running BC45\BIN\IMPLIB.DLL.
It says "Critical error during transfer". The compilation is then stopped without error.

The problem disppears if I don't include too many classes in a module. But, if I create an other module using #include,
the problem reappears with no solution...

This method works on 3 classes. The DLL uses up 80 Kb. It's impossible
to add any more classes to end up with a DLL of over 300 Kb, for example.

If I create another project using the classes from the first, I can only define 2 classes and the second DLL only uses 60 Kb, which means it's  actually smaller than the first one.

I did not define any int FAR PASCAL LibMain(HINSTANCE,WORD,WORD,LPSTR) in the dll ...

I used impdef to declare classes in the .DEF but there was no change.

How to create a DLL without being penalised by this error?
Are there examples of IDE projects of DLL containing numerous classes?
Is there an upper limit of the number of classes in a DLL?

Sometimes I also get the following error while editing the link:
"Linker fatal : Unable to open file 'C:\BC45\LIB\c0dl.obj'"
But this file exists and is not corrupted...


So, in the end, I can have a big DLL but since implib crashes, I get a .LIB of 0 byte.

0
Comment
Question by:strategem
[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
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
gaohong earned 390 total points
ID: 1163016
Your method is correct, however, your setting seems contradictary
               
                -Standard library :
                 Class library
                 Runtime
                 Static

First you canot mix static and DLL, second you are trying to make
a DLL, and it's must be dynamic.

All the problems list, I think is followup problems, once you
made correct settings, it will be OK.

My DLL is 300K under same environment as you have win16, large,
and bc++4.52

good luck
0
 

Author Comment

by:strategem
ID: 1163017
Sorry... I forgot to mention that... I had tried both static and dynamic, with identical results.
Would you like me to send you my project via E-mail?

0
 
LVL 3

Expert Comment

by:gaohong
ID: 1163018
Yes, Could you send *.ide file
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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 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.
Suggested Courses

610 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