无法在visual studio中构建.dll [英] Can't build .dll in visual studio
本文介绍了无法在visual studio中构建.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在visual studio中构建一个简单的.DLL,但是我遇到了以下错误:
智能感知:期望一个';'
智能感知:无法打开源文件stdafx.h
错误C1083:无法打开包含文件:'stdafx.h':
.dll非常简单,包含一个标题,只有一个cpp,编码如下:
标题:
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:
#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:
.cpp :
#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?
推荐答案
问题是 stdafx.h 的#include
表示它将在系统库中找到。您应该将其更改为
The problem is that your#include
for stdafx.h indicates that it will be found in the system libraries. You should change it to
#include "stdafx.h"
with双引号,因此编译器在源目录中查找它。
with double quotes, so the compiler looks for it in the source directory.
如果没有创建另一个项目并从那里复制文件,请确保您的项目包含名为stdafx.h的文件。还可以尝试更改#include< stdafx.h> #includestdafx.h。
希望,它有帮助:)
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 :)
这篇关于无法在visual studio中构建.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文