link problem in tcmalloc_minimal when using Debug-override configuration using Visual Studio on windows. · Issue #1430 · gperftools/gperftools · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Downloaded the latest gperftools 2.12 from github, built it configured it with Debug-Override x86 on windows using VisualStudio 2022。
The Debug-Override configuration is newly created by me. It is copied from Release-Override, except for the following configuration items:
c/c++ - Optimization - Optimization: Use “Disabled (/Od)” instead of “Maximum Optimization (Favor Speed) (/O2)”
c/c++ - Preprocessor - Preprocessor Definitions: Use “_DEBUG” instead of “NDEBUG”
c/c++ - Code Generation - Runtime Library: Use “Multi-threaded Debug (/MTd)” instead of “Multi-threaded (/MT)”
Link Debug-Override libtcmalloc_minimal.lib in statically with a Console APP for test purpose. Build the test app, the output is:
Build started...
1>------ Build started: Project: tcm_s, Configuration: Debug Win32 ------
1>G:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v150\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information.
1>tcm_s.cpp
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __calloc_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __free_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __malloc_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>C:\Users\muliu\Desktop\hub\tcm_s\Debug\tcm_s.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Done building project "tcm_s.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 11:01 and took 03.951 seconds ==========
My guess is that the malloc, free and calloc of the Debug version have not been hooked, right?
The text was updated successfully, but these errors were encountered:
Apparently modern ucrt does have _msize_base and _recalloc_base
defined in same .obj files as their corresponsing "non-base"
functions. And they're seemingly used somewhere in their C or C++
runtime. So lets provide them too in our override_functions.cc, so
that overriding malloc routines in MSVC's static C runtime option
works.
Otherwise, whatever msize_base usage pulls msize.obj file that wants
to define regular msize, and with msize already provided by
override_function, we'd rightfully get linking error.
Update github ticket
#1430
So I am able to link debug statically linked C runtime with latest MSVC 2022. But it crashes on some internal debugging stuff in stl map and iterators business. They do some diagnostic stuff that runs too soon and touches locks that are not yet initialized. So we'll need to implement our own scalable std::map equivalent if we want to run in this configuration on MSVC.
Other than that, I found linker error trying to link non-debug C runtime. And I fixed that in comment referenced above.
Your original issue, well, perhaps it was fixed since it was reported.
Downloaded the latest gperftools 2.12 from github, built it configured it with Debug-Override x86 on windows using VisualStudio 2022。
The Debug-Override configuration is newly created by me. It is copied from Release-Override, except for the following configuration items:
Link Debug-Override libtcmalloc_minimal.lib in statically with a Console APP for test purpose. Build the test app, the output is:
Build started...
1>------ Build started: Project: tcm_s, Configuration: Debug Win32 ------
1>G:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v150\Platforms\Win32\PlatformToolsets\v141_xp\Toolset.targets(39,5): warning MSB8051: Support for targeting Windows XP is deprecated and will not be present in future releases of Visual Studio. Please see https://go.microsoft.com/fwlink/?linkid=2023588 for more information.
1>tcm_s.cpp
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __calloc_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __free_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>libucrtd.lib(debug_heap.obj) : error LNK2005: __malloc_dbg already defined in libtcmalloc_minimal.lib(override_functions.obj)
1>C:\Users\muliu\Desktop\hub\tcm_s\Debug\tcm_s.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Done building project "tcm_s.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 11:01 and took 03.951 seconds ==========
My guess is that the malloc, free and calloc of the Debug version have not been hooked, right?
The text was updated successfully, but these errors were encountered: