Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

I think that kind of problem can arise if things are linked in the 'wrong' order. I suggest you try changing the order of whatever libraries you are passing to the linker.

(I don't actually know why the ordering matters - but it sometimes does.)

This error can occur when dependent library(where _ZNSaIcEC1Ev id defined) was compiled for other version of GLIBC (newer version or much older), that you currently have.

Try to recompile that library with your current environment.

Also you can add nice switch to LDFLAGS of your app: -Wl,--no-undefined. Then you can see any undefined symbols at compile time (not sure if it helps in your situation).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top