سؤال

I'm trying to create a Windows DLL which exports a number of functions, howver all my functions are exported but one !!

I can't figure it out.

The macro I use is this simple one :

__declspec(dllexport) void myfunction();

It works for all my functions except one. I've looked inside Dependency Walker and here they all are, except one.

How can that be ? What would be the cause for that ? I'm stuck.

Edit: to be more precise, here is the function in the .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[]
        );
}}}

And in the .cpp file it goes like this:

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);
   }

}}}

Thanks

هل كانت مفيدة؟

المحلول

I have found a work-around:

When I add __declspec(dllexport) to the function definition, in the cpp file, it is exported.

I absolutely don't know why this works, since MSDN does not seem to mention to do so.

نصائح أخرى

You care not telling enough to really help you, but here are some things you can check.

Make sure you .dll file are generated by deleting it manually and rebuild the project.

Are you also using a .def file?

Only public member functions from a class can be exported.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top