与字符串类型相关的 DLL 构建错误
3我正在学习如何使用 C++ 编写 DLL,并按照此教程视频来获取我开始了。我完全遵循,我的代码是:
defFile.def:
LIBRARY "square"
EXPORTS
square
funct.cpp:
double __stdcall square(double & x)
{
return x*x;
}
当尝试使用 VSE 2010 进行构建时,我收到以下错误:
1>------ Build started: Project: square, Configuration: Debug Win32 ------
1> defFile.def
1>c:\documents and settings\~\my documents\visual studio 2010\projects\square\square\deffile.def(2): error C2143: syntax error : missing ';' before 'string'
1>c:\documents and settings\~\my documents\visual studio 2010\projects\square\square\deffile.def(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我尝试添加 #include
at defFile.def 的顶部,但仍然得到相同的错误。我确信这真的很简单。
3I'm learning how to use C++ to write DLLs and am following this tutorial video to get me started. I follow along exactly, my code being:
defFile.def:
LIBRARY "square"
EXPORTS
square
funct.cpp:
double __stdcall square(double & x)
{
return x*x;
}
When trying to Build using VSE 2010, I get the following error:
1>------ Build started: Project: square, Configuration: Debug Win32 ------
1> defFile.def
1>c:\documents and settings\~\my documents\visual studio 2010\projects\square\square\deffile.def(2): error C2143: syntax error : missing ';' before 'string'
1>c:\documents and settings\~\my documents\visual studio 2010\projects\square\square\deffile.def(2): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I've tried adding #include <string>
at the top of defFile.def, but still get the same error. I'm sure this is something really simple.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已将 .def 文件添加到您的项目中。它的编译就像源代码文件一样。那是行不通的。
右键单击您的项目、属性、链接器、输入。将模块定义文件设置设置为“defFile.def”。
You added the .def file to your project. It is getting compiled as though it is a source code file. That can't work.
Right-click your project, Properties, Linker, Input. Set the Module Definition File setting to "defFile.def".
定义文件不是 C++。从那里删除
using namespace std;
。另外,你不应该编译它,如果你想使用它,你需要修改项目的链接器设置。Definition file is not C++. Remove
using namespace std;
from there. Also, you're not supposed to compile it, if you want to use it, you need to modify linker settings for the project.