Hi Tom,
Thank you very much for responding to my query. I did in fact figure out eventually what 'IMPEXP' was, but adding it doesn't help. In fact, even the example functions won't work! Here is the error message I got when I tried to call RectFrame from hello.c:
Error : Undefined symbol: '__declspec(dllimport) _RectFrame (__imp__RectFrame)'
referenced from '_main' in hello.c:20
hello.c line 20
Of course, the linker is seeing the declaration in the header file--I'm not getting a 'function has no prototype' error--but it can't access the definition. I've included the code which produced the above error below--only hello.c has been modified from what CW provides as example code.
It has occurred to me that since what I'm trying to link to is a dll and not just another .cpp file I want compiled, that the linker should be told to access the actual .lib file--"testutils Release.lib", which is generated in the testutils directory. However scouring the 'Settings' panel I have found no place to specify this linkage. I'm really at a loss at this point, please let me know any ideas you might have.
Best,
Matt
/**********************************************************hello.c****************************************/
#include <stdio.h>
#include "x86_Win32 DLL.h"
int main(void)
{
HDC hdc;
int d;
d = RectFrame(hdc, 1,2,3,4,5);
// d = mysum(2,3);
fprintf(stdout, "Hello World, d = !\n", d);
return 0;
}
/***********************************************************************************************************/
/*****************************************************x86_Win32 DLL.cpp, unmodified example code*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
/* Declare our exports, defining IMPEXP only inside the DLL */
#define IMPEXP __declspec(dllexport)
#include "x86_Win32 DLL.h"
/* This DLL user entry point function is only required when your application
has special initialization or termination requirements. Otherwise
the MSL runtime provides the appropriate startup code. */
BOOL WINAPI DllMain ( HINSTANCE hInst, DWORD wDataSeg, LPVOID lpvReserved );
BOOL WINAPI DllMain( HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved )
{
char buf[512];
char exename[256];
char dllname[256];
GetModuleFileName(0L, exename, sizeof(exename));
GetModuleFileName(hInst, dllname, sizeof(dllname));
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
snprintf(buf, sizeof(buf), "Process\n'%s'\nattaching to\n'%s'...", exename, dllname);
MessageBox ( GetFocus(), buf, "Notice", MB_OK|MB_SYSTEMMODAL );
return 1;
case DLL_PROCESS_DETACH:
snprintf(buf, sizeof(buf), "Process\n'%s'\ndetaching from\n'%s'...", exename, dllname);
MessageBox ( GetFocus(), buf, "Notice", MB_OK|MB_SYSTEMMODAL );
return 1;
default:
return 1;
}
return 0;
}
IMPEXP int RectFrame(HDC hdc, int x1, int y1, int x2, int y2, int t)
{
Rectangle(hdc, x1, y1, x2, y2);
Rectangle(hdc, x1+t, y1+t, x2-t, y2-t);
return 1;
}
IMPEXP int EllipseFrame(HDC hdc, int x1, int y1, int x2, int y2, int t)
{
Ellipse(hdc, x1, y1, x2, y2);
Ellipse(hdc, x1+t, y1+t, x2-t, y2-t);
return 1;
}
/***********************************************************************************************************/
/*****************************************************x86_Win32 DLL.h, unmodified example code*/
#ifndef __X86_WIN32_DLL_H__
#define __X86_WIN32_DLL_H__
#ifndef IMPEXP
#define IMPEXP __declspec(dllimport)
#endif
IMPEXP int RectFrame(HDC hdc, int x1, int y1, int x2, int y2, int t);
IMPEXP int EllipseFrame(HDC hdc, int x1, int y1, int x2, int y2, int t);
#endif /*#ifndef __X86_WIN32_DLL_H__*/
/***********************************************************************************************************/