I'm trying to make the NDK working with STL and shared libraries. For this purpose I'm using the custom made NDK from here:
http://www.crystax.net/android/ndk-r3.php
(Very nice job!!!)
However, I have few problems. I want to be able to use shared libraries in combination with STL.
For this purpose I created a library exporting 2 functions:
string sample_function_working()
{
string result="Hello world from shared lib!!!";
return result;
}
string sample_function_not_working()
{
string result="";
return result;
}
And an executable calling those 2 functions:
int main(void)
{
string test=sample_function_working();
printf("Calling sample_function_working... ");
printf("returned `%s`\n",test.c_str());
test=sample_function_not_working();
printf("Calling sample_function_not_working... ");
printf("returned `%s`\n",test.c_str());
return 0;
}
If I compile the library as static library, all works as expected:
$ adb shell /data/executable
Calling sample_function_working... returned `Hello world from shared lib!!!`
Calling sample_function_not_working... returned ``
However, if I compile the library as a dynamic library, I get a segmentation fault:
$ adb shell /data/executable
Calling sample_function_working... returned `Hello world from shared lib!!!`
Calling sample_function_not_working... returned ``
[1] Segmentation fault /data/executable
Also executed with strace and put the result here:
http://pastebin.com/8FbL22L3
The problem is with the sample_function_not_working function. Somehow, android gets confused by returning an empty string.
If you want the complete project to test it, you can find it here:
http://dl.dropbox.com/u/2918563/stests.zip
Cheers,
Andrei
------
Eugen-Andrei Gavriloaie
Web: http://www.rtmpd.com
Anyways, Dmitry, thank you so much for the time and effort invested into that custom NDK!
Cheers,
Andrei