C ++运行时符号查找错误,ubuntu(C++ runtime symbol lookup error, ubuntu)

编程入门 行业动态 更新时间:2024-10-27 20:25:21
C ++运行时符号查找错误,ubuntu(C++ runtime symbol lookup error, ubuntu)

我有一个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.4

Any ideas how to fix this?

最满意答案

当依赖库(其中_ZNSaIcEC1Ev i​​d已定义)被编译为您当前拥有的其他版本的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.

更多推荐

本文发布于:2023-07-31 09:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1342566.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   错误   ubuntu   runtime   lookup

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!