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

TOPIC:

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11353

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

Is is possible to cross-compile a library (Java native) from a Intel 64 Linux machine for ARM 64 Linux ?

I did compile/test the library (Java native) on a Rpi Linux ARM 32 and all ok (loaded from a Java class).

But how to compile it for a ARM 64 ?

The goal is to use the library for Android 64 bit (also Java class will use it).

Huh, also, if cross-compiling from a Intel 64 Linux machine for ARM 64 Linux is possible, how to do that ?

Many thanks.

Fre;D

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11354

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

I did follow the CT wiki. all seems to compile but at the end there is that error message:

/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/aarch64-linux-ld: cannot find /lib/ld-linux-aarch64.so.1
/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/aarch64-linux-ld: cannot find -lpthread
/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/aarch64-linux-ld: cannot find -ldl
/usr/local/codetyphon/fpc/fpc64/bin/x86_64-linux/aarch64-linux-ld: cannot find -lc


Any idea ?

Thanks

Fre;D

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11355

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
Thanks Sir
you must have Arm64 (aarch64-linux) OS Libraries from TARGET OS
We don't have in our Servers these OS Libraries (aarch64-linux) yet
It's a future task in our LAB To-Do list

PS: If you find any official aarch64 Linux Desktop Distribution (NOT custom builds),
we can pack aarch64-linux OS Libraries ASAP (as soon as possible)
PilotLogic Architect and Core Programmer

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

Last edit: by Sternas Stefanos.

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11356

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

Ok, thanks for your light, I will try with debian-9.3.0-arm64-DVD-1.iso (official distro of Debian).

I will try unzipping the iso and pick the needed files (I do not have a aarm64 machine that can have this distro, only a Android mobile)

Huh, by the way, do you have a idea what files of the target aarm64-iso are needed for cross compiling ?

Or, maybe, I have to be explorer (like many times ;-) ).

Thanks Sternas.

Fre;D

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11357

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

Some news from the front.

OK, it works for cross-compiling Intel64 --> ARM64.

Target OS (-T) ---> Linux
Target CPU (-P) family ---> aarch64

Just needed to add this ARM64 libraries in the host os lib-search-path:
ld-linux-aarch64.so.1, libc.so, libdl.so and libpthread.so. (Included in attachment)

File Attachment:

File Name: aarch64-li...u.tar.gz
File Size:1,358 KB


Then, with the help of your cross-chains, it cross-compiles and works like charm.

But this Java library works only on "pure" Linux ARM64 system.

For a Android ARM64 system, while trying to load the library, there is that error:

java.lang.UnsatisfiedLinkError: dlopen failed: library "ld-linux-aarch64.so.1" not found

So Android seems to not have ld-linux-aarch64.so.1 installed by default.
And even adding that library in the myproject.apk library folder did not help.

The good news is that the ELF of library is recognized and accepted by Android.

So I did try with in CT:

Target OS (-T) ---> Android
Target CPU (-P) family ---> aarch64

But when trying to compile there is that error:

Error: Illegal parameter: -Tandroid

Did I do something wrong because with -Parm (for ARM32) it works.

Thanks.

Fre;D

PS: All advices about Android world is welcome, I am absolutely beginner. ;)

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11358

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
aarm64-Linux mPC structure have BIG problem.

We test openSUSE aarm64 on our Pi3 B (16Gb SD)
but it's so slow...

We will be waiting for arm64 boards with 4Gb RAM and boot from SSD Hard disk

You can't extract libraries files from debian-9.3.0-arm64-DVD-1.iso
try openSUSE aarm64 (openSUSE-Leap-42.3-DVD-aarch64-Build0200-Media.iso) from here
ISO from here
PilotLogic Architect and Core Programmer

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11359

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
First of all
FPC trunk don't support aarm64-Android yet... :(

We fix your file with "ld-linux-aarch64.so.1" problem
after unzip has zero size, it's a link to ld-2.24.so
just copy and rename ld-2.24.so => ld-linux-aarch64.so.1
same procedure with ALL zero size files of your aarch64-linux-gnu.tar.gz file

we upload to our Servers, your modify file as "aarch64-linux-base"
you can try and
-aarch64-linux-odroidc2 or
-aarch64-linux-RapberryPi3
files

PilotLogic Architect and Core Programmer

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

Last edit: by Sternas Stefanos.

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11361

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

OK, many thanks.

> ou can't extract libraries files from debian-9.3.0-arm64-DVD-1.iso

Of course you can !

With Linux Mint, on the iso, right click + "Extract Here".
Then in directory /debian-9.3.0-arm64-xfce-CD-1/pool/main:

All the debian packages are in each alphabetic folder.

To extract a library, unzip the thepackage.deb (right click + "Extract Here").
The libraries are in /thepackage/usr/lib (or /usr/local/lib).

;)

> unzip has zero size, it's a link to ld-2.24.so

Of course. That are only links, I did use the the target-renamed.

So OK, cross-compile for ARM 64 is ok and that Java native library can be used by a Java class.

Now the challenge is to make work for Android too.

The combat continue, I am able to load the library by a Android class but I am blocked while loading some dependencies.

I will try to make a Android 32 bit apk and load the library compiled with -Tandroid -Parm (32 bit).

Maybe Android 64 is multi arch.

Thanks.

Fre;D

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

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11362

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

Pascal code + fpc = Android native library that works. ;)

For the people that are interested here how to do:

1) Use the Java arguments for all your exported methods like this (2 first parameters):

procedure MyAndroidProc(PEnv: PJNIEnv; Obj: JObject); cdecl;
begin
// do something
end;

2) Export your method using that name (maybe it is possible to change this in Java calling class but that way it works):

MyAndroidProc name 'Java_nameoftheJavaApplication_MyAndroidProc';

3) Compile your library with -Parm (for 32 bit) and -Tandroid parameters.

4) In your Android Studio project, create 2 directories and add your library into it :
- nameoftheJavaApplication/app/src/main/jniLibs/armeabi and
- nameoftheJavaApplication/app/src/main/jniLibs/armeabi-v7a

5) In Java code android, add this code to force Android Studio to compile only 32 bit application (fpc + android64 is not yet ready)
android {
    ....
    defaultConfig {
        ....
        ndk {
            abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
        }
    }
}

6) Create a Java class with all the exported method of your library (header).

7) In your main Java class, load the library with LoadLibrary().

8) Compile your apk application, transfer it to your Android mobile (with Android Studio).

9) Enjoy.

10) Many thanks to CodeTyphon and his WooooW cross-compiler chain.

Fre;D

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

Last edit: by fredvs.

Cross compile from Intel 64 Linux to ARM 64 Linux ? 6 years 1 month ago #11363

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4502
  • Thank you received: 1096
Thanks Sir
PilotLogic Architect and Core Programmer

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

  • Page:
  • 1