libsprec icon indicating copy to clipboard operation
libsprec copied to clipboard

undefined reference to 'alloca'

Open K-Y-L opened this issue 10 years ago • 6 comments

Hi, I am having the same problem as https://github.com/H2CO3/libsprec/issues/3. (I am using the rapsberry pi)

When I try to compile 'simple.c' with the following command "gcc -o simple simple.c -lsprec -lpthread" the following came up: /usr/lib/gcc/arm-linux-gnueabihf/4.8/../../../libsprec.so: undefined reference to 'alloca' collect2: error: ld returned 1 exit status

I tried to delete the library and build it again, but it doesn't work for me and I am quite stuck here. Is there a way I can fix this problem?

Thank you

K-Y-L avatar Feb 26 '15 03:02 K-Y-L

Hi,

No, in fact, you're not having the same problem. My library uses libpthread (the POSIX thread library), and that issue is about libpthread. However, my library does not use alloca(). I don't really understand why your compiler is trying to insert calls to this function, but it's not my code. What version of GCC are you using?

H2CO3 avatar Feb 26 '15 07:02 H2CO3

the version of my gcc compiler is 4.8.2 And I build libsprec(and libjsonz) by following the steps from: http://raspberrypi.stackexchange.com/questions/10384/speech-processing-on-the-raspberry-pi

K-Y-L avatar Feb 26 '15 07:02 K-Y-L

Is it something to do with the way I build libsprec and libjsonz or there is a problem with the libpthred? I can't really find any solutions to this..

K-Y-L avatar Mar 01 '15 10:03 K-Y-L

Honestly, I don't know. The code doesn't use alloca() at all; it's possible that GCC inserts calls to this function for stack-allocation of some variable, but in this case, the function should be in the libc implementation you're using. Did you make sure you have a proper cross-build of the library (i. e. you have compiled and linked a libsprec.dylib for the Raspberry Pi's architecture)? Otherwise, your build seems fine…

H2CO3 avatar Mar 01 '15 10:03 H2CO3

In fact, when I was trying to build the libsprec using "make", the following came up: image

K-Y-L avatar Mar 01 '15 14:03 K-Y-L

Hi You can fix this by defining alloca in wav.c file like this

#define alloca(x)  __builtin_alloca(x)

LHIOUI avatar May 08 '15 11:05 LHIOUI