我正在尝试创建一个Windows DLL,它导出了许多函数,但是,我的所有函数都是导出的,只有一个!
我搞不懂。
我使用的宏是这个简单的宏:
__declspec(dllexport) void myfunction();它适用于我的所有功能,除了一个。我已经看过里面的依赖沃克和这里他们都是,除了一个。
这怎么可能呢?原因是什么?我卡住了。
编辑:更准确地说,下面是.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);
}
}}}谢谢
发布于 2013-11-05 15:50:37
我找到了一个解决办法:
当我将__declspec(dllexport)添加到函数定义中时,在cpp文件中,它将被导出。
我完全不知道为什么这样做,因为MSDN似乎没有提到这样做。
发布于 2013-11-05 14:23:46
你关心的是没有说出足够的话来真正帮助你,但以下是一些你可以检查的事情。
确保通过手动删除.dll文件并重新构建项目来生成它。
您也在使用.def文件吗?
只能导出类中的公共成员函数。
https://stackoverflow.com/questions/19791023
复制相似问题