DLL 导出:并非所有函数都导出
DLL Exports: not all my functions are exported
我正在尝试创建一个导出许多函数的 Windows DLL,但我的所有函数都导出了一个!!
我想不通。
我使用的宏是这个简单的:
__declspec(dllexport) void myfunction();
它适用于我的所有功能,除了一个。我看过Dependency Walker的内部,他们都在这里,除了一个。
这怎么可能?这是什么原因呢?我被卡住了。
编辑:更准确地说,这是 .h 中的函数:
namespace my {
namespace great {
namespace namespaaace {
__declspec(dllexport) void prob_dump(const char *filename,
const double p[], int nx, const double Q[],
const double xlow[], const char ixlow[],
const double xupp[], const char ixupp[],
const double A[], int my, const double bA[],
const double C[], int mz,
const double clow[], const char iclow[],
const double cupp[], const char icupp[]
);
}}}
在.cpp文件中,它是这样的:
namespace my {
namespace great {
namespace namespaaace {
namespace {
void dump_mtx(std::ostream& ostr, const double *mtx, int rows, int cols, const char *ind = 0)
{
/* some random code there, nothing special, no statics whatsoever */
}
} // end anonymous namespace here
// dump the problem specification into a file
void prob_dump(
const char *filename,
const double p[], int nx, const double Q[],
const double xlow[], const char ixlow[],
const double xupp[], const char ixupp[],
const double A[], int my, const double bA[],
const double C[], int mz,
const double clow[], const char iclow[],
const double cupp[], const char icupp[]
)
{
std::ofstream fout;
fout.open(filename, std::ios::trunc);
/* implementation there */
dump_mtx(fout, Q, nx, nx);
}
}}}
谢谢
我找到了一个解决方法:
当我将__declspec(dllexport)
添加到函数定义时,在 cpp 文件中,它将被导出。
我绝对不知道为什么这会起作用,因为 MSDN 似乎没有提到这样做。
你不在乎说得足够多,无法真正帮助你,但这里有一些你可以检查的事情。
确保通过手动删除文件并重新生成项目来生成.dll文件。
您是否也在使用 .def 文件?
只能导出类中的公共成员函数。
相关文章:
- 是否可以将函数导入命名空间,但不能导出它?
- 如何使用导出的函数交叉编译 DLL
- error dllimport 函数的定义不允许在一个特定的联合中,而其他类、结构和联合将按预期导出
- Javascript 找不到使用 emscripten 编译的导出 WASM 函数
- PowerShell 使用结构类型参数调用 C++ DLL 的导出函数
- 从DLL导出函数,LoadLibrary()需要用TEXT转换的字符串才能编译而不会出错
- clang:使用 O3 导出隐式实例化函数的符号
- 将 Nim Anon 函数导出到C++
- 无法理解提升 python 函数导出中的语法
- DLL函数导出一个指针做Delphi程序
- 从库类函数导出 DLL 字符串
- 尽管使用了正确的dllExport-Visual Studio,但没有函数导出到DLL中
- 是否可以将具有参数表函数的函数导出到 dll
- 动态链接库函数导出
- 您可以将 Ada 泛型函数导出到C++
- 将函数导出到不带类的DLL
- c++mandelbrot函数导出全黑图像
- 如何阻止DLL中的函数导出?
- 如何在dll中创建shared_ptr并通过工厂函数导出它
- 通过函数导出检查c++插件版本