Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1

TOPIC:

Code Typhon and Android. 6 years 9 months ago #11374

  • fredvs
  • fredvs's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
Hello.

First of all, a big WOW for the CT toolchain Linux intel 64 ---> Android arm 32.
It works perfectly.

I did use it for create a Java native library (libuos.so) that works, out of the box, on a Android machine.
The library is used by a Java class.

But there is something that disturb me...

What can you do with a application compiled for Android (not a Java native library), because Android cannot deal with "classical" executable ?

Thanks for answer.

Fre;D

Please Log in or Create an account to join the conversation.

Code Typhon and Android. 6 years 9 months ago #11375

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
My friend
look here

and here

Android NDK has BIG problems...
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Code Typhon and Android. 6 years 9 months ago #11378

  • fredvs
  • fredvs's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
> Android NDK has BIG problems...

Huh, I did install first Android studio.

It install SDK out of the box, then manually install NDK without problems.

For cross-compiling C libraries, I use a custom shell (see attachment) and it cross compile ok.

For Pascal libraries ---> CodeTyphon toolchain --> OK

Then, with Android Studio, I create a pkg with a Java class that use the libraries.

And both C and Pascal libraries work perfectly on the Android machine.

So the question was:

OK to cross compile for Android a library (that can be used by a java class) but what to do with a program, could it be used by Android ?

IMO Android is a Java OS (that can not deal with "classical".ELF executable.

Fre;D

Please Log in or Create an account to join the conversation.

Last edit: by fredvs.

Code Typhon and Android. 6 years 9 months ago #11380

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
and now comes the "Dual personality" of Android

-For Low level System Libraries you can use Pascal or C/C++ ( targeting to Android NDK API)
-For Android GUI Application (native java)
--- you must use Java or FPC pas2jni info
OR
--- to make your own GUI API like CT customdrawn platform

But FreePascal Team is working on pas2js pascal to JavaScript
and I think the improve of pas2jni is the next FPC target

LAB CT 6.4 on Win64 now..

PilotLogic Architect and Core Programmer
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Code Typhon and Android. 6 years 9 months ago #11382

  • fredvs
  • fredvs's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
Hello Sternas.

Ha, ok, so, if understand ok, cross-compiling to Android will work only for native Java libraries.

And cross-compiling applications will work only with complicated translation into a Java class or Java script.

IMO, I am not fan of this, I prefer use the Java widget-set directly.

And for the complicate code, I do create a Pascal Java native library and use it by the main Java class.

Thanks for explanation Sternas.

Fre;D

Please Log in or Create an account to join the conversation.

Code Typhon and Android. 6 years 9 months ago #11385

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Have fun my friend
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Code Typhon and Android. 6 years 9 months ago #11409

  • fredvs
  • fredvs's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
Hello Sternas.

Sorry but, once again, I have a (difficult to explain) question... :blush:

If you have a C native library (for example PortAudio, Mpg123 or SndFile) and if you want to cross-compile from Linux to Android, the C
cross-compile chain add automaticaly the 2 first parameters needed for a native Android library (and Java too of course).

For example, this native method (translated in Pascal):
function mynativemethod(paramnative : integer): integer; cdecl;

will be transformed by the C cross-compiler into:
function mynativejavamethod(PEnv: PJNIEnv; Obj: JObject ; paramnative : integer): integer; cdecl;
// 2 first parameters were added

But how does the CT cross-compiler?

Does it add automatic also the 2 first parameters (PEnv: PJNIEnv and Obj: JObject) or must it done by the programmer ?

When I did use CT cross-compiler, I did add those 2 first parameters to each exported method of the Pascal library and the result is a Java native working Android library.

But now I have some doubt, maybe those parameters were also added by the CT toolchain (or by the NDK)?

Do you know if it exist a way to know the parameters needed in a exported method of a library?

Huh, I hope you did understand something...

Fre;D

Please Log in or Create an account to join the conversation.

Last edit: by fredvs.

Code Typhon and Android. 6 years 8 months ago #11438

  • fredvs
  • fredvs's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 205
  • Thank you received: 1
Hello.

I note this here in case somebody needs it (or if I forget it ;) ).

When you have downloaded and compiled the Android tool-chain and have downloaded the Android Oses libraries you may have this error messages at compiling:

/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/arm-linux-androideabi-ld.bfd: cannot find -llog
/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/arm-linux-androideabi-ld.bfd: cannot find -ldl
/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/arm-linux-androideabi-ld.bfd: cannot find -lc
uoslib.pas(511,93) Error: Error while linking


It is because the search path for those libraries was not defined.

Just add this in your fpc.cfg (according with the api you want):
(or add this parameter at compilation)
#ifdef cpuarm
-Fu/usr/local/codetyphon/binLibraries/android-4.0-api14-arm
#endif
Suggestion: Maybe CT could add this in the cross-compile chain-script.

Fre;D

Please Log in or Create an account to join the conversation.

Last edit: by fredvs.

Code Typhon and Android. 6 years 8 months ago #11441

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Just
add your Android libraries path to your project "Libraries"
like this

In CT you don't need to edit fpc.cfg for any programming action.
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.
  • Page:
  • 1