compiling someone else's vs c++ app - inconsistent linkage
hi I am not a c++ developer and I'm trying to compile someone else's app. Build succeeds, but I get 5 'inconsistent dll linkage' warnings.
the dll builds but does not work in the same scenario in which the existing dll does. there have been no code changes.
after some googling, I assume it has to do with this, found in the header file:
#ifdef CPLAPPLET_PROGRAM_EXPORTS
#define CPLAPPLET_PROGRAM_API __declspec(dllexport)
#else
#define CPLAPPLET_PROGRAM_API __declspec(dllimport)
#endif
and there's a comment in the code that says CPLAPPLET_PROGRAM_EXPORTS is defined on the command line.
The warnings happen on the exported functions, like this:
HRESUL开发者_运维问答T _stdcall CCplApplet_PROGRAM::DllUnregisterServer()
{
// our code added here
return 0;
}
can someone point me in the right direction here?
thank you.
EDIT to address comments:
I have created a c++ win32 dll project in vs 2008, and I've added their .cpp, .h, and .def files to this project, but that's all. Instead of just clicking 'build' I'm wondering if I need to do something specifically with the .def file or something?
the header file defines the methods like so:
class CPLAPPLET_LNK_PROGRAM CCplApplet_PROGRAM {
public:
static LONG APIENTRY CPlApplet(HWND hWnd, UINT uMsg, LONG lParam1, LONG lParam2);
private:
...
HRESULT _stdcall DllUnregisterServer(void);
...
};
the .def file:
LIBRARY "CplApplet_PROGRAM"
EXPORTS DllUnregisterServer PRIVATE
Right-click the project in the Solution Explorer window, Properties. Configuration Properties, C/C++, Preprocessor, Preprocessor Definitions setting. Verify that you see CPLAPPLET_PROGRAM_EXPORTS there. If you don't then add it.
It is also very likely that you'll need a .def file so that the export gets renamed. Make sure it is present in your project's list of files. After building, use Dumpbin.exe /exports on the generated DLL and ensure that the export is present and properly spelled "DllUnregisterServer" without any additional characters. Needing the help from the author isn't very unlikely btw, the way the COM exports seem to be handled is pretty nonstandard.
精彩评论