www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Problem using the DLL

reply DarenW <darenw comcast.net> writes:
This has me stumped - my DLL compiles fine (thanks to this newsgroup and docs
on the DM site) but the test program for it won't link, giving me "Symbol
Undefined":

testapp1.obj(testapp1)
 Error 42: Symbol Undefined _DestroyWaveScrawler 4
testapp1.obj(testapp1)
 Error 42: Symbol Undefined _WaveScrawler_LoadWaveFile 8
...and a few more...

yet these functions are defined in the DLL and apear in the import library,
though without the " 4" tidbits. i've no idea why the test program wants the DLL
API functions with those tidbits, while the DLL and its .lib don't provide them.
Relevant simplified toy-version snippets of source follow.  I hope it's just
a silly option i'm forgetting, or something "obvious"... well at least i'm the
proud father of a shiny new DLL that seems to be ok, just can't use it!



---begin  mydllapi.h ----
#define DLLAPI  __declspec(dllimport)   __stdcall
extern "C"
BOOL  DLLAPI WaveScrawler_Blah(...);
--- end mydllapi.h ---

--- begin mydll.cpp ---
#define DLLAPI  __declspec(dllexport) __stdcall
#include "mydllapi.h"
extern "C"
BOOL  DLLAPI WaveScrawler_Blah(...)
{...}
--- end mydll.cpp ---

--- begin DLL's makefile ----
.cpp.obj:
	dmc -WD -c -g -mn -w- -o $   $<

mydll.dll: mydll.obj $(COREOBJ) coredll.def
	dmc mydll.obj $(COREOBJ) coredll.def

mydll.lib: mydll.DLL
	implib  /noi mydll.lib  mydll.DLL
----end makefile ----

--- testapp1.cpp ---
#include <windows.h>
#include "mydllapi.h"
int PASCAL WinMain(HANDLE inst, HANDLE previnst, LPSTR cmd, int nShow)
{
 WaveScrawler_Blah(...);
}
--- end testapp1.cpp ---

build testapp1.exe with:
  dmc -mn testapp1.cpp mydll.lib
Feb 13 2007
parent Bertel Brander <bertel post4.tele.dk> writes:
DarenW skrev:
 This has me stumped - my DLL compiles fine (thanks to this newsgroup and docs
 on the DM site) but the test program for it won't link, giving me "Symbol
 Undefined":
 
 testapp1.obj(testapp1)
  Error 42: Symbol Undefined _DestroyWaveScrawler 4
 testapp1.obj(testapp1)
  Error 42: Symbol Undefined _WaveScrawler_LoadWaveFile 8
 ...and a few more...
 
 yet these functions are defined in the DLL and apear in the import library,
 though without the " 4" tidbits. i've no idea why the test program wants the
DLL
 API functions with those tidbits, while the DLL and its .lib don't provide
them.
 Relevant simplified toy-version snippets of source follow.  I hope it's just
 a silly option i'm forgetting, or something "obvious"... well at least i'm the
 proud father of a shiny new DLL that seems to be ok, just can't use it!

Have a look at: http://damb.dk/dllfiles.php If needed, I can have a look at your code later tonight. What is in your coredll.def file? -- Just another homepage: http://damb.dk But it's mine - Bertel
Feb 13 2007