<div dir="ltr"><div><div><div><div><div><div>Hi again!<br>This mail is the continuation of the Androids threads problem. <br>As you guys said, the threads problem seems to be caused by using a old version of the compiler, so I went and compiled fpc from trunk, for Android target.<br>
</div>Then I tried compiling my game using the cross compiler I just built.<br></div><br>I had to make some changes to the compilation options:<br>Replaced -Tlinux with -Tandroid<br></div><div>Replaced -CfVFPV2 with -CfVFPV3<br>
</div>Removed -mfloat-abi=hard<br></div>Added new unit path (units\rtl-objpas, seems it was necessary for dateutils now)<br><br></div>And then it compiled fine, generated a .so, like before. All seems ok, so I compile my java code, and make an apk. When I try running the game now it crashes at startup.<br>
<br>D/dalvikvm( 5667): Trying to load lib /data/data/com.terra.minimon3d/lib/libterraARMV7.so 0x424967b8<br>E/AndroidRuntime( 5667): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1307]: 111 cannot locate 'PASCALMAIN'...<br>
<br></div>Strange... So I run nm on the .so file to check exported symbols.<br><div><div>D:\code\minimonhd\trunk\Android\libs\armeabi-v7a>nm -g libterraARMV7.so<br> U FPC_THREADVARTABLES<br> U INITFINAL<br>
U PASCALMAIN<br></div><div>(and others, calloc, malloc, FPC_RESOURCESTRINGTABLES, etc)<br><br></div><div>Where are my own exported JNI functions, they are gone?<br>I had like 30 of them, that were correctly exported with an older FPC.<br>
</div><div><br>Confused by this, I compile the game again, but this time with the older FPC version.<br>I then run nm on the .so and the functions are all there...<br>0005aa08 T JNI_OnLoad<br>0005aa34 T JNI_OnUnload<br>00059b30 T Java_com_pascal_terra_TERRALibrary_ApplicationContextLost<br>
00059b2c T Java_com_pascal_terra_TERRALibrary_ApplicationGetOrientation<br></div><div>Etc...<br></div><div>Something curious, PASCALMAIN is not anywhere in the export symbols now. And I don't even understand why this is being called when I load the library in the Java side?<br>
</div><div><br>My own exported functions are all declared in the main file. <br>They are defined like this:<br><br>Procedure Java_com_pascal_terra_TERRALibrary_ApplicationShutdown(env, obj:Pointer); stdcall; export; [public];<br>
</div><div>Begin<br></div><div>...<br></div><div>End;<br><br>Note that even in the old compiler, if the functions are defined outside the main file they were not exported, compiler bug or some kind of limitation? <br></div>
<div>Also the part "export; [public];" seems necessary in Android, otherwise they were also not exported correctly. I don't really understand what [public] means, and sadly could not find documentation about it.<br>
Finally, in the end of the main file I have an exports section, listing all functions I want to export, all worked before so what changed that causes the symbols to not be exported in the .so?<br><br><div>And why is this PASCALMAIN being exported, since I'm compiling a library not a program?<br>
<br></div><div>Here's the complete compilation options I'm using, just in case I'm missing something<br>-TAndroid
-a -Parm -CpARMV7 -CfVFPV3 -gl -vewnhi -Xd -Sg -O-
-XParm-linux-androideabi- -FUbuild -FEandroid\libs\%TARGET_OUTPUT%\
-olibterra%TARGET%.so <br></div><div>(plus fpc\units\rtl, rtl-objpas and 10 other paths belonging to my own units)<br><br></div></div><div>Regards,<br></div><div>Sérgio<br></div></div></div>