|
From: Edward D. <eld...@tr...> - 2010-09-28 01:35:41
|
On 9/27/2010 1:01 PM, Martin Mocko wrote: > On Mon, Sep 27, 2010 at 4:10 PM, Edward Diener > <eld...@tr... > <mailto:eld...@tr...>> wrote: > > My experience with __declspec(dllimport) with VC++ is that a header file > automatically dllimports whatever is necessary when using a dll. Thta is > why I am not used to doing it manually. > > > I am not sure I understand correctly what you were meaning, but all that > the __declspec(dllimport) does in VC++ is that it adds external symbol > "__imp__<decorated name>" to resulting object file. Nothing more. You > still have to specify .lib file which defines this symbol to linker > command line (manually, or using #pragma comment(lib, "file"), or even > #pragma comment(linker, "file.lib") ) I understand this. But once the correct lib is being imported I don't have to manually declare __declspec(dllimport) on some exported symbol because a header file which I am using which representatives some entities for that lib will automatically do it for me. The header file code will look something like this: #if defined(BUILD_DLL_XXX) #define EXPIMP_XXX_SYMBOLS __declspec(dllexport) #else #if defined(USING_DLL_XXX) /* this can usually be determined automatically by whether the end-user is linking with the library as a static library or dll */ #define EXPIMP_XXX_SYMBOLS __declspec(dllimport) #else #define EXPIMP_XXX_SYMBOLS #endif #endif and then: EXPIMP_XXX_SYMBOLS class SomeClass etc. This technique of having a library automatically export or import symbols is well known. That is why the warning message I encountered seemed strange to me, and not because I do not know exactly what exporting and importing symbols from a shared library means. |