Board index » cppbuilder » Using non-VCL DLL with a VCL Application

Using non-VCL DLL with a VCL Application

I have a problem trying to use a non-VCL DDL with a VCL application. I
export a class from this DLL and every time the application deletes a
created object from this class it generates an Access Violation.

My questions are:

1. Is it possible to use a non-VCL DLL from a VCL application?
2. In case (1) is affirmativ, how to allow this use?

Thanks,
Marcelo Leister.

 

Re:Using non-VCL DLL with a VCL Application


I'm using some DLLs that are, in fact, non VCL related, and I have no
problems.

Could it be something in the class definition that is making the problem?

I had some [strange] problems with exporting and importing classes from VCL
DLL's, and the actual problem was in the class definition, not in the Exe or
the DLLs

My class was:

class __export TNameMe : public TCollectionItem
{

Quote
}

this was causing problems, so, what I did, (I don't remember where I saw the
info, I think here) was:

#ifdef COMPILING_THE_DLL
    #define KIND_OF_DLL __export
#else
    #define KIND_OF_DLL __import
#endif

class KIND_OF_DLL TNameMe : public TCollectionItem
{

Quote
}

And this solved all the problems.

HTH

Rodrigo Gmez

"MLeister" <marcelo_leis...@ch.schindler.com> escribi en el mensaje
news:3B457A87.5060203@ch.schindler.com...

Quote
> I have a problem trying to use a non-VCL DDL with a VCL application. I
> export a class from this DLL and every time the application deletes a
> created object from this class it generates an Access Violation.

> My questions are:

> 1. Is it possible to use a non-VCL DLL from a VCL application?
> 2. In case (1) is affirmativ, how to allow this use?

> Thanks,
> Marcelo Leister.

Re:Using non-VCL DLL with a VCL Application


Thanks Rodrigo for your hint, but it does not solve my problem. Let me
explain it better.
I have a class CTest like
****************
#ifdef __DLL__
   #define DECLSPEC __export  
#else
   #define DECLSPEC __import  
#endif

class DECLSPEC CTest //: public Node
{
  public:
     CTest(void) {};
     ~CTest(void) {};

Quote
};

****************
and that is compiled with static RTL.

When using this DLL on a VCL application with static or dynamic RTL
(doesn't matter) my application crashes when deleting the point to an
object of this class. If I use dynamic RTL with the DLL it works fine
with a VCL application also with dynamic RTL. But due to pre-requisites
I have to use static RTL in the DLL.

----------------------------------------------------------------------------------------------
|                           | VCL application w/ static RTL | VCL
application w/ dynamic RTL |
----------------------------------------------------------------------------------------------
|non-VCL DLL w/ static RTL  |         Crashes               |            
Crashes             |
----------------------------------------------------------------------------------------------
|non-VCL DLL w/ dynamic RTL |         Crashes               |            
  OK                |
----------------------------------------------------------------------------------------------

Is there someone else with a hint?

Thanks a lot,
Marcelo Leister.

Quote
Rodrigo Gmez wrote:
> I'm using some DLLs that are, in fact, non VCL related, and I have no
> problems.

> Could it be something in the class definition that is making the problem?

> I had some [strange] problems with exporting and importing classes from VCL
> DLL's, and the actual problem was in the class definition, not in the Exe or
> the DLLs

> My class was:

> class __export TNameMe : public TCollectionItem
> {
> }

> this was causing problems, so, what I did, (I don't remember where I saw the
> info, I think here) was:

> #ifdef COMPILING_THE_DLL
>     #define KIND_OF_DLL __export
> #else
>     #define KIND_OF_DLL __import
> #endif

> class KIND_OF_DLL TNameMe : public TCollectionItem
> {
> }

> And this solved all the problems.

> HTH

> Rodrigo Gmez

> "MLeister" <marcelo_leis...@ch.schindler.com> escribi en el mensaje
> news:3B457A87.5060203@ch.schindler.com...

>> I have a problem trying to use a non-VCL DDL with a VCL application. I
>> export a class from this DLL and every time the application deletes a
>> created object from this class it generates an Access Violation.

>> My questions are:

>> 1. Is it possible to use a non-VCL DLL from a VCL application?
>> 2. In case (1) is affirmativ, how to allow this use?

>> Thanks,
>> Marcelo Leister.

Other Threads