Re: LNK4006 in .NET 2003

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



piwiix wrote:
Let's explain the structure of my solution :
- under Visual Studio .Net 2003
- I've got all source files
- 1st library BasicLibrary.lib : class defined in BasicClass.h implemented
in BasicClass.cpp
[...]
- 2nd library DepLib1.lib -> only dependends on BasicLibrary.lib, no
include - 3rd library DepLib2.lib -> only dependends on BasicLibrary.lib,
no include - 4th library TopLibrary.lib -> dependends on BasicLibrary.lib,
DepLib1.lib and DepLib2.lib, no include
- Dependencies are intended to make header files available in only one
directory and avoid many include paths.
- All libraries have same preprocessors definitions (WIN32;_DEBUG;_LIB)
and runtime library types (/MLd)

Results :
- Compilation of BasicLibrary.lib : OK
- Compilation of DepLib1.lib : OK
- Compilation of DepLib2.lib : OK
- Compilation of TopLibrary.lib : NOK even though only warnings are
displayed

DepLib2.lib(BasicClass.obj) : warning LNK4006: "public: __thiscall
CBasicClass::CBasicClass(void)" (??0CBasicClass@@QAE@XZ) already defined
in BasicLibrary.lib(BasicClass.obj) ; second definition ignored

The reason is that, other than would be the case for e.g. a DLL, a static
library that links another static library then includes that library
completely, instead of just referencing that lib. Therefore, symbols of
BasicLibrary are duplicated in the other two libs.

Can you explain me please how to get rid of these warnings WITHOUT pragma
directives or using FORCE option or changing dependencies ?
Or is it simply impossible ???

I've never seen the need to use the IDE's dependencies for headers, didn't
even know it worked. So, if you could change includes so that you don't
need multiple dependencies on one static lib that should solve your
problems. Other than that, I only see that you could change to creating
DLLs which don't suffer said problems.

Uli


.



Relevant Pages

  • Re: Im getting frustrated and angry!
    ... foo.o is never dependent on bar.o thus there cannot be circular dependencies. ... There basically are two models of compilation, the C way where everything is in textual source code or the Java way where the compiler uses the output of the compilation of other sources rather than the text itself. ... "Safeness of make-based incremental compilation, the key result of this paper, can be stated as follows: Suppose we build a program brute-force, and then edit the source files, and possibly the makefile as well. ...
    (comp.lang.java.help)
  • Re: Preliminary analysis of existing ASDF practices
    ... Allow action writers to specify dependencies based on this data. ... So whatever compilation and loading tool we will want can ... New actions might even add conventions to the asdform above. ...
    (comp.lang.lisp)
  • Re: PCRE & MFC: problem with link error
    ... Here is a link to the vc6 project with source files. ... I have successfully built your source code so that the PcreText.exe uses the ... "PcreTest files", then activate the Project |Dependencies menu item, and ...
    (microsoft.public.vc.mfc)
  • Re: Separate Compilation in Programming Languages
    ... project, compilation is not cheap. ... RB> But there is a way to manage explicit dependencies: ... model of separate compilation at that point where one can separate the ... the implementation of the Interface not to the Interface abstraction. ...
    (comp.lang.ada)
  • Re: Problem linking static libs with common dependencies
    ... >> in the Librarian view of the project settings for A) an as a result I get ... > automagically tries to link its lib or export library to the dependee. ... static lib projects don't have a linker options view. ... I have used project dependencies in many ...
    (microsoft.public.dotnet.languages.vc)