[program-l] Re: Calling function in c++ dlls

  • From: "Sean Farrow" <s0201608@xxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Wed, 9 Mar 2005 17:29:32 -0000

Hi: 
I hav base classes and some inherited ones, hence have many header files,
how do I get round this problem, and how do I export a class, what is the
format for doing this for example: 
class test{ 
public: 
Void testFunc(char string); 
}; 
how would I export this?
Cheers
 
Sean Richard Farrow,
Student, Sound Studio Technology,
North-East Wales Institute Of Higher Education.
Tel.: +44(0) 7747081574
E-mail: s0201608@xxxxxxxxxx
 
 

  _____  

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Will Pearson
Sent: 09 March 2005 16:59
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Calling function in c++ dlls


Hi Sean,
 
Yes, you would have to declare them as DLLEXPORT and DLLIMPORT, but in the
header, not in the cpp file, assuming you're placing your declarations in a
header.  The easiest way to do this is with preprocessor macros in the
header.  Something like
 
// MyDLL.h
 
#ifdef CREATING
#define IMPORTEXPORT DLLEXPORT
#else
#define IMPORTEXPORT DLLIMPORT
#endif
 
void IMPORTEXPORT MyFunc();
 
// end of .h
 
// MyDLL.cpp
 
#define CREATING
/* let the compiler know we're creating the DLL so that it can apply the
right convention */
 
// write code
 
If you're using a DLL Export File (.DEF), then you don't have to do this, as
you use the .def file to declare what functions/classes should be exported.
 
You'll have three files after compilation and linking: the .h, a linker stub
(.lib), and a .DLL.  You'll need to number include the .h in the project
where you wish to use the DLL, as well as specifying the .lib as input to
the linker.  Then, at run-time, the easiest place in the DLL search path to
place your DLL is in the folder that the ..exe you're running is located in.
 
Will

----- Original Message ----- 
From: Sean Farrow <mailto:s0201608@xxxxxxxxxx>  
To: program-l@xxxxxxxxxxxxx 
Sent: Wednesday, March 09, 2005 9:51 AM
Subject: [program-l] Re: Calling function in c++ dlls

Hi: 
A coupple of questions following up from the last message: 
1. Does it matter that the functions are within classes? 
2. do I need to declare the functions as export/import in the dll/main
program? 
Cheers 
 
Sean Richard Farrow,
Student, Sound Studio Technology,
North-East Wales Institute Of Higher Education.
Tel.: +44(0) 7747081574
E-mail: s0201608@xxxxxxxxxx
 
 

  _____  

From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Laura Eaves
Sent: 09 March 2005 09:26
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Calling function in c++ dlls


Don't you have the header files for the library implemented in the dll?
Just call the functions like you normally would.
--le
 

----- Original Message ----- 
From: Sean  <mailto:s0201608@xxxxxxxxxx> Farrow 
To: program-l@xxxxxxxxxxxxx 
Sent: Wednesday, March 09, 2005 3:48 AM
Subject: [program-l] Calling function in c++ dlls

Hi: 
I need to call functions inside a c++ dll with classes from a c++ program?
what is the best way of doing this? 
Cheers
 
Sean Richard Farrow,
Student, Sound Studio Technology,
North-East Wales Institute Of Higher Education.
Tel.: +44(0) 7747081574
E-mail: s0201608@xxxxxxxxxx
 
 

Other related posts: