1) I'm using the Borland C++ verision
I go to FILE >> New >> OTHER and choose Dynamic Link Library
2 Files Pop Up. Project1 and Unit1.cpp
With the .cpp file I rename it as TestDLL.cpp, below is the following code:
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
void __stdcall SayHello(void)
{
PRINTF("Hello");
}
then I create a .h file called TestDll.h, code is the following
#ifndef MAIN_DLL_UNIT_H
#define MAIN_DLL_UNIT_H
#ifdef __cplusplus
extern "C"
{
#endif __declspec(dllexport) void __stdcall SayHello(void);
#ifdef __cplusplus
};
#endif /* __cplusplus*/
#endif /* MAIN_DLL_UNIT_H */
Then I open a console application
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
#include #include #include "MainDLLUnit.h"
int main(int argc, char* argv[])
{
SayHello();
getch();
return 0;
}
I get the following error "Unresvoled external 'SayHello' referecned..."
what am I doing wrong?
Comments
That is, unless you want a dll. In that case you have to rewrite your main() program.
: I was reading in the book that you have to compile the DLL and
: you'll find a .lib file. I am not getting a .lib file. What could
: be wrong?
:
In the menu file >new choose other,in the window that appears at that moment
choose wizard.another window appears.
There you will create your Dll.
Normally when you compile,check that the compilation options and the options of the projects enable creating a DLL.
The compilation should yield a .lib that can be statically linked and a .dll.
Also check that you created a .def file containing the entry points and enumerations of the functions.Though its not that necessary.