Re: LNK4006 warnings turning to LNK2005 errors, help please



On Fri, 21 Oct 2005 11:17:02 -0700, "George P Boutwell"
<GeorgePBoutwell@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> 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.
>
>Any suggestions or ideas?

Non-inline functions defined in headers tend to give you multiple
definition errors. Member functions defined outside a class are non-inline
by default. You should either define member functions inside the class
body, or you should declare them inline. Non-member functions must be
declared inline if you define them in headers. The exception concerns
templates, because the compiler will permit multiple non-inline
instantiations of a template specialization and discard all but one.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Compile DLL created in Visual C++
    ... How can I compile the DLL that I created in Visual C++ in the windowz ...
    (comp.os.linux.development.apps)
  • Re: VBA and VSTO
    ... If you compile in VB6 with Global MultiUse than all you have to do is set a reference in Excel to your dll via Tools, References and you can access your functions in the dll directly. ... You will have to register the dll as well with Windows with Regsvr32, but that can be done quite simply in VBA. ...
    (microsoft.public.excel.programming)
  • Re: HOW CAN I OPEN A COM PROJECT COMPILED IN VS2005, IN VS2003?
    ... I keep getting the .exe output when I compile in the VC7. ... the General Configuration Type to be .dll in the Project Property. ... Microsoft MVP, MCSD ... instead create my own folders for file grouping... ...
    (microsoft.public.win32.programmer.ole)
  • GlobalMultiUse component breaks its compatibility !!!
    ... I have a component (ActiveX dll) with only one class in it. ... compiled, even though the binary compatibility is set, a new UUID is ... Public Property Let MyStringProp(ByVal vNewValue As String) ... Compile the project. ...
    (microsoft.public.vb.com)
  • LNK2020 using managed/unmanaged classes combination and workaround question
    ... mark 'DLL' and 'Export Symbols'). ... this is a managed class added to the DLL. ... To the Windows Forms project, ... make sure you compile everything with /clr. ...
    (microsoft.public.dotnet.languages.vc)