Re: Strange linker errors (LNK2005) in Release build only .... why ??

Tech-Archive recommends: Fix windows errors by optimizing your registry



There is way, "dont use c-runtime library". If the number of trivial CRT
function u need are less then it is quite possible, as sometimes there are
typical win32 wrappers for certain functions.

nanda

"Krishnan R.S." <rskrishnan@xxxxxxxxxxx> wrote in message
news:eCwmjEi5FHA.3976@xxxxxxxxxxxxxxxxxxxxxxx
> So is there no way to override/replace malloc/free with my implementation
in
> a dll ??
>
> Thanks,
> Krishnan
>
> "Nanda" <nandagopal.seshagiri@xxxxxxxxx> wrote in message
> news:eTkBJbe5FHA.884@xxxxxxxxxxxxxxxxxxxxxxx
> > Hi,
> >
> > U are seeing this problem only in release build because, in debug, the
> free
> > and malloc are exported or used as _free_dbg and _malloc_dbg from
> > msvcrt70d.dll, where as in release they are exported as free and malloc.
> >
> > nanda
> >
> > "Krishnan R.S." <rskrishnan@xxxxxxxxxxx> wrote in message
> > news:%23$H7jjV5FHA.3636@xxxxxxxxxxxxxxxxxxxxxxx
> > > Hello All,
> > >
> > > First off I'd like to say I am not mixing the static and dll
> versions
> > of
> > > the runtime in my dll - I use /MDd for the debug and /MD for the
release
> > > versions of DLMAlloc.dll. I tried all sorts of options for the linker
> but
> > it
> > > seems adamantly stuck on not building the release version alone!
> > >
> > > I've got a project where I'm trying to use dlmalloc.c instead of
the
> > > usual vc7 malloc() - i.e. I want to build a drop in replacement for
the
> > > default vc7 malloc() allocator. To use this allocator in all my dlls I
> > need
> > > to build this as a separate dll - called say DLMalloc.dll.
> > >
> > > I've attached a zip file containing the source + the vcproj files
if
> > you
> > > are interested ...
> > >
> > > I have a project in MSVC 7.1 setup to build a dll (not a static
> lib) -
> > > all seems fine in the debug build. I am able to build my DLMalloc.dll,
> and
> > > DLMalloc.lib - and use it to build my app, successfuly links and works
> > too!
> > >
> > > The problem comes when I try to build a release build of
> > > DLMalloc.dll/DLMalloc.lib. The compile goes fine - but I get a linker
> > error.
> > > The linker thinks that _free and _malloc are defined multiple times -
> why
> > ??
> > >
> > > Why do I get this symbol conflict only on release builds ? I
suspect
> > that
> > > the MSVCR71.dll has internally linked to the malloc/free
implementations
> > > available in the runtime - is that possible ?? If so why does it work
> on
> > > the debug build ??
> > >
> > > I tried switching to incremental linking on the release build
(using
> > > /OPT:NOREF /OPT:NOICF with /INCREMENTAL) but no luck whatsoever.
> > > I tried looking at the verbose output of the linker - and it seems
> > like
> > > the reference to free is from crtdll.obj - see snippet below.
> > >
> > > ---snippet from the verbose linker output ---
> > > Found __imp__free
> > > Referenced in MSVCRT.lib(crtdll.obj)
> > > Loaded MSVCRT.lib(MSVCR71.dll)
> > > MSVCRT.lib(MSVCR71.dll) : error LNK2005: _free already defined in
> > malloc.obj
> > > --- end snippet ----
> > >
> > > I may very well be on the wrong track with my diagnosis ....
> > > I'd appreciate any help you can give me on this issue.
> > >
> > > Thanks,
> > > Krishnan
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>


.



Relevant Pages

  • Re: Strange linker errors (LNK2005) in Release build only .... why ??
    ... Krishnan ... >> First off I'd like to say I am not mixing the static and dll ... >> all seems fine in the debug build. ... >> the MSVCR71.dll has internally linked to the malloc/free implementations ...
    (microsoft.public.vc.stl)
  • Re: How to connect to children process
    ... Main problem is amount of manual operations required per debug cycle. ... connection to DLL with debugger takes sensible amount of time and manual ... Is the main problem that the debugger keeps symbols file loaded ... AFAIK that's how VS2003 debugger works, but WinDbg should usually ...
    (microsoft.public.vsnet.debugging)
  • Re: running a service/driver/application upon startup
    ... Would it be possible for you to drop a debug services.exe and debug nk.exe ... > I ran dumpbin/exports on the finger dll and saw the required function ... >> theories as to why it's not getting loaded but just doing 'services load ...
    (microsoft.public.windowsce.embedded)
  • Re: technical/OS problem (windows xp?)
    ... Build a debug version of the ISAPI DLL. ... Create a virtual root with execute permissions in the IIS Management ... Add your ISAPI extension or filter DLL to the list. ...
    (alt.marketing.online.ebay)
  • Pthread debug DLL uses non-debug VC runtime; include its manifest to resolve this
    ... where I could not start up a debug version of a console app. ... the pthreads DLL, from other comments in the thread. ... Dependency Walker revealed that the Pthreads debug ... It turns out that you need not only the .dll files, but the .manifest files as well. ...
    (microsoft.public.vsnet.debugging)