[Gc] Experiences/Issues on Windows with Visual Studio/C++
martin.wartens at mymail.ch
Sun Apr 2 15:48:22 PDT 2006
I am curious if somebody is using the gc on Windows (XP) with VC7.1 or VC8.0. I
had some success building the gc as a static library. For the Release
configuration I use the additional gc flags
And for the Debug configuration:
When linking the gc library in debug mode with "REDIRECT_MALLOC=GC_malloc"
switched on, the linker complains "LNK2005 _calloc, _malloc... already
defined". The solution is to set
"gc.lib ...other libs in the middle... LIBCMTD.lib"
"Ignore specific library":
"Command Line->Additional Options:"
This forces the linker to take the definitions of malloc etc. from the gc.lib.
It is not a nice solution. (LIBCMTD.lib is the static multi-threaded debug-C-
Another patch is necessary to make this work. In malloc.c, line 434, it must
To my surprise the definitions of the global "new" operators in gc_cpp.cc are
not affected by the REDIRECT_MALLOC malloc flag. So I edited that file to
replace GC_MALLOC_UNCOLLECTABLE by GC_MALLOC.
I tried to add the "GC_THREADS" flag when building the gc, since I am using the
multi-threaded C-library (which is the only option in VC8.0). But then the
program crashes during the init phase, when calling "FASTLOCK();" in malloc.c,
line 316. My program doesn't use threads right now, but I get some spurious
errors during calls to C-library functions. I suspect they could be caused by
building the gc without "GC_THREADS".
I made short try to build and use a .dll-version, but I wasn't succesful. There
was a crash in the init phase. Maybe someone can add something to my
More information about the Gc