Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

Welcome, Guest
Guest Settings

Thread: How to generate an Android library (.so) with C++Builder to use in Delphi?

This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Permlink Replies: 0
Alejandro Rosa

Posts: 23
Registered: 10/30/09
How to generate an Android library (.so) with C++Builder to use in Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 6, 2015 1:14 PM

Sorry, my english is bad.

I have mixed solution on Android: a library in C++Builder (It's package project) and an app "front end" in Delphi (XE7 Rad Studio).
I have a several error when I use the library... I try 2 times, using external and using dlopen.

The library is like the following example:

        // H
        extern "C" {
            UnicodeString __declspec(dllexport) __stdcall PackageTestFunc1( int aID );
        // CPP
        UnicodeString __declspec(dllexport) __stdcall PackageTestFunc1( int aID )
           return UnicodeString(L"Hola");

1) When i use with "external" Delphi keyword, the code is:

        {$ifdef MSWINDOWS}
           function PackageTestFunc1( i : integer ) : string; stdcall; external 'PackageTest.bpl';
        {$ifdef ANDROID}
           function PackageTestFunc1( i : integer ) : string; stdcall; external ''; // or 'libPackageTest.a' with same problem
        procedure TForm6.FormCreate(Sender: TObject);
          Caption  := PackageTestFunc1( 77 );

When compile Tester.exe in Delphi/Win32, and PackageTest.bpl in C++Builder/Win32, work fine.
When compile Tester.exe in Delphi/Android, and in C++Builder/Androd, linker fails in Delphi:

[DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\android-ndk-r9c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: S:
Debug/ in function PackageTestFunc1:S:\Organizer\PackageTest/Unit6.cpp:13: error: undefined reference to 'System::UnicodeString::UnicodeString(wchar_t const*, int)'

This sounds like Delphi is statically linking the .so file...

2) When I using "dynamically" with dlopen, I get the following error (dlerror):

   Cannot load library: get_lib_extents[742]: 158 - /data/..../ is not a valid ELF object.

What happend with my .so file generated with C++Builder????

Edited by: Alejandro Rosa on May 6, 2015 5:15 PM
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02