Re: LNK4006 warnings turning to LNK2005 errors, help please



"George P Boutwell" <GeorgePBoutwell@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:76404BE6-5B28-4103-9992-C29DBA741DF6@xxxxxxxxxxxxxxxx
> I have a static library and a dll developed in another environement.
> I've
> been working on porting them and I have most the issues worked out of
> them.
> The problem I'm seeing now is that the static library and dll compile fine
> in
> the other environment, but get an huge amount of warnings during the
> library
> on lots of symbols which seem to be the same symbols that turn into error
> LNK2005 when I compile the DLL (it uses the library).
>
> As near as I can tell the symbols that are being problematic are
> functions
> and methods that are defined (not just declared, but have a body too) in
> the
> header files. I've tested this theory by moving some of the
> implementations
> to the unit and that fixes them. I was wondering if there is a compiler
> switch or something where I could tell it to not treat the function as an
> error in that situation. There are a lot of them and the library and dll
> work just fine in the other environment.

Functions that are defined in header files in header files need to be inline
function or they'll be multiply defined.

If you're writing C, there's no portable way to do this, but VC++ recognizes
the non-standard __inline decoration. If you're writing C++, just add
inline to your function declaration and you're good to go.

inline void foo() {}

-cd


.



Relevant Pages

  • Re: Odd behavior of getenv and putenv
    ... Recently I have observed some odd behavior of getenv and putenv function. ... This sounds like the modules (EXE, DLL) are using different CRTs and thus ... you could link everyone to the same CRT DLL so they would share CRT state. ... So it seems that getenvand systemlook at different environment. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: How do I set the environmet for a dll?
    ... KB-Q78542 (Retrieving MS-DOS Environment Vars from a Windows DLL) ... I don't think that setting things in the registry is going to ... > DllMain, I can't think of an elegant solution, but here are a couple of ...
    (microsoft.public.win32.programmer.kernel)
  • Properly build a atl/com DLL File
    ... I have built an ATL/COM DLL using an MSVC++ ... V6.0 environment. ... I have added some more features to this DLL. ...
    (microsoft.public.vc.atl)
  • Re: Odd behavior of getenv and putenv
    ... Recently I have observed some odd behavior of getenv and putenv function. ... This sounds like the modules (EXE, DLL) are using different CRTs and thus ... you could link everyone to the same CRT DLL so they would share CRT state. ... the new process inherits the environment of the process that started ...
    (microsoft.public.dotnet.languages.vc)
  • Re: How do I set the environmet for a dll?
    ... Are you sure the dll is retrieving environment variables? ... GetEnvironmentVariable -- do you know how this dll is doing it? ...
    (microsoft.public.win32.programmer.kernel)