Re: Problem with a DLL and a Static Library



Carl Daniel [VC++ MVP] wrote:
Mihai Popescu wrote:
In my DLL project, in the header file, I have this macro:
#ifdef AGE_EXPORTS
#define AGE_API __declspec(dllexport)
#else
#define AGE_API __declspec(dllimport)
#endif

In the header file of the LIB, I put the previous preprocessor
directives. I've inlcuded the same(phisical) header file in the DLL
project and in the GUI, as in the LIB.

What's the value of AGE_EXPORTS when building the LIB? It looks like it's not defined but it should be.

-cd

-cd

Well, I guess it's not defined when building the LIB so AGE_API would become __declspec(dllimport). That's why I get that
"warning C4273: inconsistent dll linkage ".
I've also tried also to define AGE_API as an empty macro during LIB linkage, puting the following directives into LIB-s header files.

#ifdef DLL
#ifdef AGE_EXPORTS
#define AGE_API __declspec(dllexport)
#else
#define AGE_API __declspec(dllimport)
#endif
#else
#define AGE_API
#endif

Then I define DLL macro in the DLL project and in the GUI (#define DLL) before including header files (from the LIB directory).

But now, I get linker errors and new warnings:
"LNK2019: unresolved external symbol"
"warning C4005: 'AGE_API' : macro redefinition"

I guess I'll have to ignore previous warnings...even if I wonder why this second method doesnt work.
Of course there is a logical reason...but I don't get-it... That's why I'm asking for help... :D

Best regards! Mihai
.



Relevant Pages

  • Problem with Borland C++ 5.02
    ... I am developing an application for ISA DLL driver for some equipment ... LIB into the LIB path and directory of compiler, ...
    (comp.lang.c)
  • Problem with linking - cant find the right solution.
    ... I am developing an application for ISA DLL driver for some equipment ... LIB into the LIB path and directory of compiler, ...
    (comp.lang.c)
  • Re: implicit loading of dll ?
    ... copy the lib and dll to the debug folder or the release folder... ... Paul T. ... to worry about putting its data in the precompiled header file. ...
    (microsoft.public.windowsce.app.development)
  • Re: Specific details on building and using dll and lib files
    ... dll or lib files. ... to have the dll, lib, as well as header file. ... I would need to have both the lib and header file. ... the compiler has no idea what exists or how to access it... ...
    (comp.programming)
  • Re: share data between dlls
    ... 2dll project name is awWebBubbleSDK so i m using this in class header file ... COM DLL LIB --1 ...
    (microsoft.public.vc.language)

Loading