__stack_chk_fail_local error on 32-bit Linux (Ubuntu 10.04.1 LTS)
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Kaustubha Govind
2011-3-21
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
2011-7-22
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!