Forum

× CodeTyphon Cross-Build Development, discussions and problems

Question Code Typhon and Android.

  • fredvs
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 2 weeks ago #11374 by fredvs
Code Typhon and Android. was created by fredvs
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.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
9 months 2 weeks ago #11375 by Sternas Stefanos
Replied by Sternas Stefanos on topic Code Typhon and Android.
My friend
look here

and here

Android NDK has BIG problems...

CodeTyphon Architect and Programmer

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

  • fredvs
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 2 weeks ago - 9 months 2 weeks ago #11378 by fredvs
Replied by fredvs on topic Code Typhon and Android.
> 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
Attachments:
Last edit: 9 months 2 weeks ago by fredvs.

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

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
9 months 2 weeks ago - 9 months 2 weeks ago #11380 by Sternas Stefanos
Replied by Sternas Stefanos on topic Code Typhon and Android.
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..


CodeTyphon Architect and Programmer
Attachments:
Last edit: 9 months 2 weeks ago by Sternas Stefanos.

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

  • fredvs
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 1 week ago #11382 by fredvs
Replied by fredvs on topic Code Typhon and Android.
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.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
9 months 1 week ago #11385 by Sternas Stefanos
Replied by Sternas Stefanos on topic Code Typhon and Android.
Have fun my friend

CodeTyphon Architect and Programmer

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

  • fredvs
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
9 months 2 days ago - 9 months 2 days ago #11409 by fredvs
Replied by fredvs on topic Code Typhon and Android.
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
Last edit: 9 months 2 days ago by fredvs.

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

  • fredvs
  • Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
More
8 months 4 weeks ago - 8 months 4 weeks ago #11438 by fredvs
Replied by fredvs on topic Code Typhon and Android.
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
Last edit: 8 months 4 weeks ago by fredvs.

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

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
8 months 4 weeks ago - 8 months 4 weeks ago #11441 by Sternas Stefanos
Replied by Sternas Stefanos on topic Code Typhon and Android.
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.

CodeTyphon Architect and Programmer
Last edit: 8 months 4 weeks ago by Sternas Stefanos.

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