Title: dlsym returning symbol not found in android after succesful return of dlopen
Tags: android;linux
Question: I am loading one shared library from another. Lets say foo2.so from foo1.so

I am using dlopen followed by dlsym

dlopen succeed with proper handle but dlsym returns with "symbol not found" error .I have used dlerror to print the error.

These are the things i tried. In foo2.so .mk file I added 
LOCAL_LDFLAGS += -Wl,--export-dynamic.

I checked the symbol in foo2.so using nm and it is there.

Both the modules are in C except one wrapper file in foo1.so which is in C++, Calling file is in C.

Can any one suggest whether i missed any thing . I am running this on android emulator on froyo.



Here is another answer: I would be tempted to poke around at the implementation level and verify things.  Look in /proc/PID#/maps and make sure both libraries are loaded.  

objdump both caller and callee and make sure that C++ bit didn't mangle the name.  

Are you using a suitable RTLD_ flag, and is dlsym getting a valid handle returned by dlopen ?

Can you build (a simplified version of) the two libraries and test executable for a desktop linux or cygwin in order to make sure what you want to do is generally workable - ie, that the problem is android-specific?

Comment for this answer: Sample code is entered below pHndl = dlopen(pTemp, RTLD_NOW);
   if ((err = dlerror()) != NULL) {
   LOGE("Error in loading shared lib: %s",err); dlerror();
    }
   dlsymRet =  (OMX_PTR)dlsym(pHndl,pFuncName);
   if ((err = dlerror()) != NULL) {
   LOGE("Error symbol not found : %s",err);
 }
Comment for this answer: it returns valid handle. tried RTLD_LAZY as well. Both the caller and callee resides in a c file so will it name mangling in remaining C++ file matters. regarding the map file i need to check in media player process. This code was workign perfectly on linux. Trying to load openmax components dynamically onto our core. Need to check the id of media player process .

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:11/02/10', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><linux>', 'Title': 'dlsym returning symbol not found in android after succesful return of dlopen', 'ViewCount': 2711, 'id': 4077452, 'user_AboutMe': None, 'user_AccountId': 665377.0, 'user_DisplayName': 'Aslam', 'user_Reputation': 1.0, 'user_Views': 3.0, 'user_id': 494706.0}}