indra
indra

Reputation: 832

undefined reference by the shared lib during linking to application

For one of my c++ based application I making some of my code as shared lib(c++ devlopment only) and I link to my test application to access the services of the shared lib . everything work fine when I am doing on linux .. Since I have developed this for arm based embedded system . I tried to cross compile my shared lib and application using arm cross tool chain set-up on linux platform. I have written a makefile to create a shared lib and compile my application . when I do the cross compile my library gets created but while linking to the application it gives the following error .

lib/arm//libserviceclient.so: undefined reference to `std::basic_string, std::allocator >::_S_compare(unsigned int, unsigned int)'

libserviceclient.so.0.2.0 is my shared lib and below are the links libserviceclient.so.0 -> libserviceclient.so.0.2.0 libserviceclient.so -> libserviceclient.so.0

so I thought this is the problem with libstdc++ and I used that link in the make file

if I link static lib in my makefile -L/usr/local/cross/arm/arm-none-linux-gnueabi/libc/armv4t/usr/lib/libstdc++.a it compiles but if I link shared arm-none-linux-gnueabi/libc/armv4t/usr/lib/libstdc++.so then it throws same error .

wouldnt be this libstdc++ linked by default if I use c++ ? Can someone help to fix this issue .

Upvotes: 0

Views: 735

Answers (1)

indra
indra

Reputation: 832

I could solve this problem ,, there was mis macth in the version of stdc++ which I was using on the development system and target system .. I used that same version on both , now it works .. thanks guys for your help

Upvotes: 0

Related Questions