[MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

fredvs
Hello everybody.

Is is possible to cross-compile a library (Java native) from a Intel 64
Linux machine for target 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



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

mse
Administrator


On 01/29/2018 02:48 PM, fredvs wrote:
> Hello everybody.
>
> Is is possible to cross-compile a library (Java native) from a Intel 64
> Linux machine for target ARM 64 Linux ?
>
Which compiler?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

fredvs
> Which compiler?

FPC (or MSElang, of course).

OK, the people of CodeTyphon did a excellent work.
Their Cross tool chain work perfectly:

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

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.

Then, with the help of the CT cross-chains, it 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.
(I do use Android Studio --> WoW).

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

The not so good news is that Android seems to use a other loaded than
ld-linux-aarch64.so.1.

So I did try with this parameters in FPC:

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

But when trying to compile with FPC there is that error:

Error: Illegal parameter: -Tandroid

So, to resume:

fpc -Tandroid -Parm ==> Compiles ok

fpc -Tandroid -Paarch64 ==> Compiles NOT ok ==> Error: Illegal parameter:
-Tandroid

Maybe fpc -Tandroid -Paarch64 is not ready yet...

PS: All advices how to create with FPC (or MSElang ) a Android native
library is welcome.

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

mse
Administrator


On 29.01.2018 19:23, fredvs wrote:
>> Which compiler?
> FPC (or MSElang, of course).
You compile with FPC (Free Pascal) a library written in Java? I probably
misunderstood.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

fredvs
> You compile with FPC (Free Pascal) a library written in Java?

No, I compile Pascal source with FPC, to obtain a Java native library.

The goal is that a Java class use that library.

It works for OS (Win, Linux, FreeBSD)  + Java installed on Intel 32/64.
For ARM 32/64 with Linux and FreeBSD it works too.

But for ARM 64 + Android, the library fail to load because of missing
dependencies.
(See my previous post for explanations).

At the moment, I will try to build a Android-apk 32 bit with Android Studio.
Then try to load a 32 bit fpc library compiled with the -Parm (for 32 bit)
and -Tandroid.

Maybe Android 64 bit machine are multi-arch.

Huh, what a combat again.

Thanks.

Fre;D








--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

mse
Administrator

> Huh, what a combat again.
>
I feel with you. :-(

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] Cross compile from Intel 64 Linux to ARM 64 Linux ?

fredvs
Hello Martin.

The combat was hard but I win the war ;)

It works, 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 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.


Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk