Search code examples
c++ubunturuntimeundefined-symbol

C++ runtime symbol lookup error, ubuntu


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?


Solution

  • 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.