__stack_chk_fail_local error on 32-bit Linux (Ubuntu 10.04.1 LTS)
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey guys,
I need some advice regarding running a piece of code with MATLAB. The underlying code is in C++ and uses the MEX utility to interface with MATLAB. I am able to compile the code, but when I run it I get the error:
??? Invalid MEX-file '/home/pbhat/Downloads/lsm/csim/csim.mexglx':
/home/pbhat/Downloads/lsm/csim/csim.mexglx: undefined symbol:
__stack_chk_fail_local.
Some details about my platform : I am running MATLAB R2010b on Linux 32-bit (Ubuntu 10.04.1) and my gcc /g++ compiler version is 4.3 which according to http://www.mathworks.com/support/compilers/R2010b/linux.html is the currently supported version.
I did quite a bit of search and found two pieces of advice from people who have faced this problem before:
- Add -fno-stack-protector to the CFLAGS in the Makefile of the C++ code
- Add -lgcc_eh and libc_nonshared.a to the LDFLAGS in the Makefile of the C++ code
Based on these recommendations I edited the mex options to now look like this:
CFLAGS='-fPIC -ansi -D_GNU_SOURCE -pthread -fexceptions -m32 -fno-stack-protector'
LDFLAGS=" -lgcc_eh /usr/lib/libc_nonshared.a -pthread -shared -m32 -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
But the error still persists. I am really out of ideas here. Has anyone faced this issue before?
Thanks for your help!
0 commentaires
Réponses (2)
Kaustubha Govind
le 21 Mar 2011
I'm not familiar with this problem, but from your modifications to the mex options file, you are not adding libc_nonshared.a correctly. You should use:
LDFLAGS=" -lgcc_eh -lc_nonshared -pthread -shared -m32 -Wl,--version-script,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
When you add "-lc_nonshared", the "lib" is prepended to the library name.
Anunay Pandey
le 22 Juil 2011
M also trying to compile the csim code on a Ubuntu 10.10 machine and am getting the same error as below
csimclass.o: In function `csimClassInfo::listFields()': csimclass.cpp:(.text+0x19f66): undefined reference to `_stack_chk_fail_local'
armmodel.o: In function `ArmModel::loadData(bool)': armmodel.cpp:(.text+0xe47): undefined reference to `__stack_chk_fail_local'
armmodel.o: In function `ArmModel::ArmModel()': armmodel.cpp:(.text+0x1caf): undefined reference to `__stack_chk_fail_local'
armmodel.o: In function `ArmModel::ArmModel()': armmodel.cpp:(.text+0x20e7): undefined reference to `__stack_chk_fail_local' /usr/lib/libstdc++.a(eh_alloc.o): In function `global constructors keyed to eh_alloc.cc': (.text._GLOBAL__I_eh_alloc.cc+0x82): undefined reference to `__stack_chk_fail_local'
/usr/lib/libstdc++.a(cp-demangle.o):(.text+0x4127): more undefined references to `__stack_chk_fail_local' follow collect2: ld returned 1 exit status
mex: link of ' "csim"' failed.
I still get the same error even after trying to change the CFLAGS and LDFLAGS of the mex option file. Any help will be great if you managed to get past the error !!
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!