我有一个C ++函数doSth,它将从类“canMsg”调用函数“checkFrame”,如下所示
#include "canMsg.h" void doSth(char* canFrame){ map<int, double> returnedData; CANMsg canMsg; std::cout<<canFrame <<endl; canMsg.checkFrame(canFrame); }在编译期间我没有收到任何错误,但是当我运行它时,它执行std::cout<<canFrame <<endl; 通过创建错误声明和崩溃
undefined symbol: _ZNSaIcEC1Ev, version GLIBCXX_3.4任何想法如何解决这一问题?
I have a C++ function doSth that will call a function "checkFrame" from a class "canMsg" as shown below
#include "canMsg.h" void doSth(char* canFrame){ map<int, double> returnedData; CANMsg canMsg; std::cout<<canFrame <<endl; canMsg.checkFrame(canFrame); }During compilation I receive no error, but when I run it, it executes std::cout<<canFrame <<endl; statement and crashes by creating an error
undefined symbol: _ZNSaIcEC1Ev, version GLIBCXX_3.4Any ideas how to fix this?
最满意答案
当依赖库(其中_ZNSaIcEC1Ev id已定义)被编译为您当前拥有的其他版本的GLIBC(更新版本或更旧版本)时,可能会发生此错误。
尝试使用当前环境重新编译该库。
你也可以添加一个很好的开关到您的应用程序的LDFLAGS:-Wl, - no-undefined。 然后你可以在编译时看到任何未定义的符号(不确定它是否对你的情况有帮助)。
Thanks for the replies. The error was due to my attempt to return a locally declared pointer. After I changed the local pointer variable to a static, it works perfect. The basic idea is C++ does not advocate to return the address of a local variable to outside of the function.
Look this for more information.
更多推荐
发布评论