libsprec
libsprec copied to clipboard
undefined reference to 'alloca'
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
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?
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
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..
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…
In fact, when I was trying to build the libsprec using "make", the following came up:
Hi You can fix this by defining alloca in wav.c file like this
#define alloca(x) __builtin_alloca(x)