Windows linking problem (defaultlib 'LIBCMT' conflicts with use of other libs)

865 views
Skip to first unread message

Xiaomei Ji

unread,
May 10, 2012, 7:06:55 PM5/10/12
to chromi...@chromium.org

I tried to build views_unittests in Windows and got the following error:

202>Linking...
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __malloc_dbg already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __calloc_dbg already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __expand already defined in allocator.lib(jemalloc.obj)
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __free_dbg already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(heapinit.obj) : error LNK2005: __heap_init already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(heapinit.obj) : error LNK2005: __heap_term already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(heapinit.obj) : error LNK2005: __get_heap_handle already defined in allocator.lib(allocator_shim.obj)
202>LIBCMTD.lib(heapinit.obj) : error LNK2005: __crtheap already defined in allocator.lib(allocator_shim.obj)
202>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
202>../..\build\Debug\views_unittests.exe : fatal error LNK1169: one or more multiply defined symbols found
202>Project : warning PRJ0018 : The following environment variables were not found:
202>$(DXSDK_DIR)
202>Build log was saved at "file://d:\chromium\trunk\src\build\Debug\obj\views_unittests\BuildLog.htm"
202>views_unittests - 11 error(s), 1 warning(s)


The value of (views_unittests property pages ->Configuration properties -> C/C++ ->Code generation ->Runtime Library) is  "Multi-threaded Debug (/MTd)".

From msdn doc, seems that the above error is caused by the objects are building with different runtime library.
But I did a fresh rebuild using VS2008 (wipe out build/Debug and closed VS before sync, then run "gclient sync --force", then run "GYP_DEFINES="disable_nacl=1" gclient runhooks", then rebuild views_unittests).

I tried to use /NODEFAULTLIB (set in Linker->Input->Ignore All Default Libraries), but that caused a lot of unresolved symbols.

Anyone experienced the same problem (it used to work for me a while ago).

Thanks,
Xiaomei

Alex Pakhunov

unread,
May 10, 2012, 7:12:55 PM5/10/12
to x...@chromium.org, chromi...@chromium.org
IIRC this kind of error can be fixed by adding dependency on "base/allocator/allocator.gyp:allocator" to the failing target.

Alex.

--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

John Bates

unread,
May 25, 2012, 5:09:08 PM5/25/12
to alex...@google.com, x...@chromium.org, chromi...@chromium.org
I'm getting something similar today linking chrome_main_dll. Also tried fresh build on a checkout from today. Halp?

GYP_DEFINES: remove_webcore_debug_symbols=1 fastbuild=1 disable_nacl=1

27>------ Build started: Project: chrome_main_dll, Configuration: Release Win32 ------
27>Linking...
27>allocator.lib(allocator_shim.obj) : error LNK2005: __msize already defined in libcmt.lib(msize.obj)
27>allocator.lib(allocator_shim.obj) : error LNK2005: __get_heap_handle already defined in libcmt.lib(heapinit.obj)
27>allocator.lib(allocator_shim.obj) : error LNK2005: __heap_term already defined in libcmt.lib(heapinit.obj)
27>allocator.lib(allocator_shim.obj) : error LNK2005: "int __cdecl _set_new_mode(int)" (?_set_new_mode@@YAHH@Z) already
defined in libcmt.lib(new_mode.obj)
27>allocator.lib(allocator_shim.obj) : error LNK2005: _malloc already defined in libcmt.lib(malloc.obj)
27>allocator.lib(allocator_shim.obj) : error LNK2005: _free already defined in libcmt.lib(free.obj)
<...>
Reply all
Reply to author
Forward
0 new messages