Tuesday 15 July 2014

c++: definition of dllimport function not allowed, building with visual studio 2010 -


I'm one. I am using Visual Studio 2010 to build Dll.

  // trialDLL.h #ifndef TRIALDLL_H_ #define TRIALDLL_H_ // ... the MyMathFuncs class omitted definition #ifdef __cplusplus extern "C" {#endif #ifdef TRIALDLL_EXPORT: I as a wrote up tests #define TRIALDLL_API __declspec (dllexport) #else #define TRIALDLL_API __declspec (dllimport) #endif TRIALDLL_API MyMathFuncs * __stdcall new_MyMathFuncs (double offset); TRIALDLL_API zero __stdcall del_MyMathFuncs (MyMathFuncs * myMath); TRIALDLL_API double __stdcall MyAdd (MammothFunks * Ma Math, Double A, Double B); // any other similar storage #ifdef __cplusplus} #endif #endif   

and triallDLL.cpp file:

  // trialDLL.cpp #include "TrialDLL .h "TRIALDLL_API MyMathFuncs * __stdcall new_MyMathFuncs {double offset} {returns new mimefunks (offset); } TRIALDLL_API zero __stdcall del_MyMathFuncs (MyMathFuncs * myMath) {delete myMath; } TRIALDLL_API double __stdcall MyAdd (MyMathFuncs * myMath, double A, double b) {myMath- & gt; Add (A, B); } // ... some other definitions   

With these two files in this project, I added the project through the Visual Studio 2010 property managers and TRIALDLL_EXPORT Users After all these macros, good intelligence gives me an error for each function defined in the .cpp file and "error: declares a function '' dllimport 'can not be defined". So it appears that Intellisense TRIALDLL_EXPORT is not defined I thought if I could actually build the project, then you will not make any difference, but the results will suggest the same error : "Error C2491: 'new_MyMathFuncs': Definition of dllimport is not allowed". So it is clear that macro TRIALDLL_EXPORT is still not defined at compile time in #define TRIALDLL_EXPORT trialDLL.cpp, but it does not help: < P> After failing to add a macro through Visual Studio, I also tried to insert the code line. I wonder what is the proper way to do this? How do I inform the compiler that Micro so that TRIALDLL_API is defined by dllexport instead of dllimport ?

Also evaluates, if I can successfully create .dll, is there a systematic way to test / verify Dell's functionality?

Thanks for any help in advance! (Although I know that there is an issue here on stackoverflow to put appreciation in this question, I feel unwelcome to myself, to do so. Forgive me for any inability due to these lines.)

VS Property sheet has nothing to do with preprocessor macros of "User macros" in the section of the property sheet, put TRIALDLL_EXPORT C / C ++> Preprocessor & gt; Preprocessor Definitions

"User Macros," which can only be defined in the asset sheet, allows you to create your own "variables" which are used in Visual Studio properties Can be done, code> $ (target name) , $ (SolutionDir) etc.

No comments:

Post a Comment