VC++ .NET 2002: Error C1803 in creation of a simple regular DLL

G

Guest

Hi all,
I used 'Empty Project'/native C++ of the VC++ .NET 2002 to do 'Build' for the SimpleRegular.cpp and SourceFile.h files of the attached code of creation of a simple regular DLL and I got an Error C1083 - can not find or open <stdafx.h>. Is <stdafx.h> already built in the VC++ .NET system? What is wrong in this coding to do 'Build'? Can someone help and point out what is wrong with this coding and how to correct it?
Thanks in advance,
Scott Chang
----------------------------------------------
//////---SimpleRegularDLL.cpp---///////////
# include <stdafx.h>
# include "SourceFile.h"

class CDllApp : public CWinApp
{
public:

CDllApp::CDllApp()
{
Calc(0,0);
}

DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CDllApp,CWinApp)

END_MESSAGE_MAP()

CDllApp DllObject;
///////---SourceFile.h------/////////
extern "C" _declspec(dllexport) int Calc(char no1,char no2)
{
char result;
result = no1 + no2;
return result;
}
 
S

Steve McLellan

The file you mention is a file generated by the Project Wizard, so if you
created an Empty Project you won't have it. Just try commenting out the
include.

Steve

Scott Chang said:
Hi all,
I used 'Empty Project'/native C++ of the VC++ .NET 2002 to do 'Build' for
the SimpleRegular.cpp and SourceFile.h files of the attached code of
creation of a simple regular DLL and I got an Error C1083 - can not find or
open <stdafx.h>. Is <stdafx.h> already built in the VC++ .NET system? What
is wrong in this coding to do 'Build'? Can someone help and point out what
is wrong with this coding and how to correct it?
 
S

Steve McLellan

Hi Scott,

In 2) I meant if you change the line
#include "stadfx.h"
to
// #include "stdafx.h"

it won't try to compile that file, which you don't have anyway. If you've
chosen 'Empty Project' this will be the case.

To create a project that has the stdafx.h file with it, you can go to New
Project -> Win32 Project -> Select DLL and DON'T click 'Empty Project'.

It sounds like the code you're trying to compile has been copy and pasted
from a tutorial or something; see if it's got any clues on the project
configuration they used.

Steve

Scott Chang said:
Thanks Steve,
1) Is any Project Wizard in VC++ .NET 2002 for me to do the regular DLL
that needs #include <stdafx> ? I did not see 'Project Wizard' in my VC++
..NET 2002. I tried the 'Managed C++ Project' for the file I had and I got 5
errors (C2504, C2143, C2061, and C2146 twice) and 1 warning (C4183) when I
did 'Build'. Please help and tell me what 'Project Wizard' in VC++ .NET 2002
I can use to do the regular DLL programming.
2) I do not understand what you mean by 'Just try commenting out the
include'. If I tried to use '#include "stdafx.h" in the 'Epmty project' and
did 'Build', I got the same 5 errors and 1 warning mentioned above. Please
give me some detailed instructions to correct this program to get the DLL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top