Quote:Original post by Woltan
well, as far as i know, the way i do it works just as fine. The only difference is, that i do define DECLSPEC when i compile the exe and I dont when I compile my dll.
Unless I am mistaken I dont think that this is the error, since this is exactly the same way how i import my other dll into my project.
Any other suggestions?
It is definitely wrong, because in your code, inside else section what you have is "DECLSPEC _declspec(dllimport)" - there is no "#define" in front of it (there's only "#else", as far as i know - everything on the same line as "#else" is ignored, so basicaly you just have an empty #else section).
//DLLImport.h#ifndef DECLSPEC#define DECLSPEC _declspec(dllexport)#else DECLSPEC _declspec(dllimport)#endif
So that's one. Second thing is, that you are defining the same symbol twice. I don't think there are any compilers that wouldn't give you an error or at least a warning on such thing. So that is why, you should either use other symbol to indicate when to export and when to import from DLL OR you should undefine the symbol before redefining it. Here are both solutions:
1) use different symbol (my previous example):
/DLLImport.h#ifndef _EXPORTS#define DECLSPEC _declspec(dllexport)#else#define DECLSPEC _declspec(dllimport)#endif
2) undefine the symbol before redefining it:
/DLLImport.h#ifndef DECLSPEC#define DECLSPEC _declspec(dllexport)#else#undef DECLSPEC#define DECLSPEC _declspec(dllimport)#endif
NOTE: you should always compile your code with the maximum warning level and you should fix all warnings (so there is none).