[Gc] GC_MALLOC doesn't compile..

Boehm, Hans hans.boehm at hp.com
Thu Mar 9 15:24:06 PST 2006


It looks like you either:
 
- forgot to link against the gc library, or
- forgot the -c on the gcc command line,
 
depending on whether or not you had intended to link the program.
 
In any future posts, please include the GC version and platform (e.g.
Linux/X86).
 
Hans


________________________________

	From: gc-bounces at napali.hpl.hp.com
[mailto:gc-bounces at napali.hpl.hp.com] On Behalf Of Renaud Dubois
	Sent: Thursday, March 09, 2006 2:06 PM
	To: gc at napali.hpl.hp.com
	Subject: [Gc] GC_MALLOC doesn't compile..
	
	
	Hi,
	
	I'm writing a compilation option to add the C garbage collector
in my program:
	/* for the garbage collector */
	#ifdef GARBAGE_COLLECTOR
	#include "gc.h"
	#define malloc(n)               GC_MALLOC(n)
	#endif
	
	
	
	I have set the GC_INIT in the header of the main().
	
	int main(int argc, char **argv){
	        int register i = 0;
	        int fdcom;
	
	        GC_INIT();
	
	
	And for the "free()":
	
	        /* free dynamic memory */
	#ifndef GARBAGE_COLLECTOR
	        free(tab_flow);
	#endif
	
	
	But when i try to compile, I have the following error:
	gcc -I/usr/local/include/ -DDEBUG -DGARBAGE_COLLECTOR -O2
-march=i486 -Wall   -o module1 module1.o
	module1.o: In function `initialisation_tab_flow_struct':
	module1.c:(.text+0x3ad): undefined reference to `GC_malloc'
	collect2: ld returned 1 exit status
	make: *** [module1] Error 1
	
	"initialisation_tab_flow_struct" is a small function where I do
a malloc call:
	     
	       if((tab_flow = malloc(number * sizeof(struct flow))) ==
NULL){
	                perror_time("Memory allocation failed !\n");
	                exit(EXIT_FAILURE);
	        }
	
	Thank you for your help..
	
	Yours faithfully,
	
	Renaud Dubois
	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://napali.hpl.hp.com/pipermail/gc/attachments/20060309/1a0b130e/attachment.htm


More information about the Gc mailing list