Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;DLL不导出我的函数_C++_Visual Studio 2010_Dllexport - Fatal编程技术网

C++ C++;DLL不导出我的函数

C++ C++;DLL不导出我的函数,c++,visual-studio-2010,dllexport,C++,Visual Studio 2010,Dllexport,我搜索过谷歌和这个网站的所有地方,我所做的似乎与我所读到的内容相符。我使用VS 2010 C++快件。在DLL上调用dumpbin/exports时,我没有看到列出任何函数 以下是我的DLL代码中仅有的内容。我需要C++中的任何特殊标题吗?< /P> C++头文件: extern "C" { __declspec(dllexport) int __cdecl AddOne(int start); } C++CPP文件: extern int __cdecl AddOne(int sta

我搜索过谷歌和这个网站的所有地方,我所做的似乎与我所读到的内容相符。我使用VS 2010 C++快件。在DLL上调用dumpbin/exports时,我没有看到列出任何函数

以下是我的DLL代码中仅有的内容。我需要C++中的任何特殊标题吗?< /P> C++头文件:

extern "C"
{
    __declspec(dllexport) int __cdecl AddOne(int start);
}
C++CPP文件:

extern int __cdecl AddOne(int start)
{
    return start + 1;
}

我错过了什么明显的东西吗?函数是否必须位于名称空间、静态类或任何内容中?我现在只想做一些基本的工作。

如果您认为它没有导出,请尝试查看结果dll中的符号。在,您可以找到有关如何导出的更多信息。我看不到您的代码中有错误。外部“C”和“cdecl”并不重要。它们控制链接器的入口点装饰方式。它们不控制是否从DLL或可执行文件中导出。顺便说一句,EXE可以像导出任何其他DLL一样导出入口点。DLL可以调用驻留在.EXE中的函数,方法与调用任何其他DLL中的函数相同

关键元素是uu declspec(dllexport)。这似乎是正确的


检查您的头文件是否真的包含在您的cpp文件中,并尝试在项目的属性页中使用各种选项的变体。

我不认为您尝试将其实现为
\uuuuu declspec(dllexport)int\uu cdecl AddOne(int start){…}
?只是尝试了一下,但似乎不起作用。将头文件添加到cpp文件修复了它。我知道这很简单。谢谢在我的情况下,这是一个签名不匹配。参数在cpp文件中没有常量。已为此问题挣扎了2天,此响应解决了我的问题。故意登录StackOverflow只是为了竖起大拇指。