Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm trying to build a simple .DLL in visual studio but i'm getting the following errors:
IntelliSense: expected a ';'
IntelliSense: cannot open source file "stdafx.h"
error C1083: Cannot open include file: 'stdafx.h':

The .dll is very simple and contains one header and just a cpp, coded as follow:
header:
C++
#ifndef INDLL_H
#define INDLL_H

#ifdef EXPORTING_DLL
extern __declspec(dllexport) int Triple(int);
#else
extern __declspec(dllimport) int Triple(int);
#endif

#endif

.cpp :
C++
#define EXPORTING_DLL

#include <stdafx.h>
#include "Header.h"

void APIENTRY DllMain()
{
	return TRUE;
}

int Triple(int x)
{
	return x * 3;
}



What's wrong here?
Posted

The problem is that your #include for stdafx.h indicates that it will be found in the system libraries. You should change it to
C++
#include "stdafx.h"

with double quotes, so the compiler looks for it in the source directory.
 
Share this answer
 
Make sure that your project contains file with name stdafx.h if not create another project and copy the file from there. Also try changing #include <stdafx.h> to #include "stdafx.h".

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900