problem of linking libraries with GC_MALLOC

J

jitender001001

hi all
I have a problem of linking static libraries with GC_MALLOC, I
have made my routine smaller to make it simpler. I m using fedora 7
kernel version 2.6.18-1.2798.fc6

void
str_check_alloc( char **str, int required, int size)
{
int init_reqd, space2alloc;
if( size == 0) {
init_reqd = 1;
space2alloc = required;
}
else {
init_reqd = 0;
space2alloc = size*2;
}

if (init_reqd) {
*str = GC_MALLOC(space2alloc);
(*str)[0] = '\0';
} else
*str = GC_REALLOC(*str, space2alloc);
}

name of main program is "test_toupper.c" which calls this routine
"str_check_alloc" internally.
i m extracting executables in "test_toupper"

gcc -static -g -DINLINE= -I../../../install/include test_toupper.c -
L../../../install/lib -lgc -lsvcr -lm -o test_toupper

.../../../install/lib/libsvcr.a(libsvcr_a-str.o): In function
`str_check_alloc':
/work/anonymous/svc/libsvcr/str.c:47: undefined reference to
`GC_realloc'
/work/anonymous/svc/libsvcr/str.c:44: undefined reference to
`GC_malloc'



I have added "gc.h" library also but still it is showing undifined
reference to GC_MALLOC
what can be the problem.

Regds

Jitender
 
I

Ian Collins

hi all
I have a problem of linking static libraries with GC_MALLOC, I
have made my routine smaller to make it simpler. I m using fedora 7
kernel version 2.6.18-1.2798.fc6
Wrong group, try a Linux one.
 
R

Richard Tobin

/work/anonymous/svc/libsvcr/str.c:47: undefined reference to
`GC_realloc'

This is referring to a reference to GC_realloc in libsvcr. Your own
code doesn't use GC_realloc, it uses GC_REALLOC (unless that's a macro
referring to GC_realloc).
gcc -static -g -DINLINE= -I../../../install/include test_toupper.c -
L../../../install/lib -lgc -lsvcr -lm -o test_toupper

Presumably you need to swap the order of -lgc and -lsvcr, so that
references from libsvcr to libgc will get resolved.

-- Richard
 
C

CBFalconer

Richard said:
This is referring to a reference to GC_realloc in libsvcr. Your
own code doesn't use GC_realloc, it uses GC_REALLOC (unless
that's a macro referring to GC_realloc).

This doesn't exist in standard C, and is thus off-topic. I don't
know where you should go, but it's not here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top