Question

I've searched Google and all over this site and it seems like what I am doing matches the stuff I have read. I'm using VS 2010 C++ Express. When I call dumpbin /exports on the DLL, I don't see any functions listed.

Here are the only things I have in my DLL code. Do I need any special headers in the C++?

C++ Header File:

extern "C"
{
    __declspec(dllexport) int __cdecl AddOne(int start);
}

C++ CPP File:

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

Am I missing something obvious? Does the function have to be in a namespace or static class or anything? I'm just trying to do the basics right now.

Was it helpful?

Solution

I do not see errors in your code. Extern "C" and __cdecl are not important. They control how your entry point is decorated for the linker. They do not control if it should be exported out of your DLL or executable or not. By the way .EXE can export entry points in the same way as any other DLL. DLLs can call functions that reside in .EXE in the same way as in any other DLL.

The key element is __declspec(dllexport). It seems to be correct.

Check if your header is really included into your cpp file and try variants with various options in the property pages of your project.

OTHER TIPS

If You think it's not exported try dependency walker and CFF Explorer to see the symbols inside of a resulting dll. At MSDN You can find some more information about how to export

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top