Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Delphi Linker error



Permlink Replies: 4 - Last Post: Apr 24, 2016 6:48 AM Last Post By: Eray HANOGLU
Alejandro Rosa

Posts: 23
Registered: 10/30/09
Delphi Linker error
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2015 8:50 AM
Hi

Sorry,my english is bad.

I have a BPL created with C ++ Builder XE8 Win32, Mac, iOS Device and Android, using the RTL and STL.
This bpl is used from a Delphi FMX application. In the desktop OSs is dynamically loaded (.dll and .dylib respectively). In mobile it is statically linked, accordingly.
In the first 3 platform's everything works OK, but in Android gives Delphi linker errors that do not know how to solve.

Linker errors are many, but all similar: multiple definition problems between Delphi libs and Android STL lib, ex:

MSBUILD : error E2597: E2597 C:\Users\Public\Documents\Embarcadero\Studio\16.0\PlatformSDKs\android-ndk-r9c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: error: C:\\Users\\Public\\Documents\\Embarcadero\\Studio\\16.0\\PlatformSDKs\\android-ndk-r9c\\sources\\cxx-stl\\gnu-libstdc++\\4.8\\libs\\armeabi-v7a/libgnustl_static.a(eh_terminate.o): multiple definition of 'std::terminate()'
MSBUILD : error E2597: C:\Users\Public\Documents\Embarcadero\Studio\16.0\PlatformSDKs\android-ndk-r9c\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: c:\\program files (x86)\\embarcadero\\studio\\16.0\\lib\\Android\\Release/librtlhelper.a(terminate.o): previous definition here


I could reproduce the problem on a small project: https://dl.dropboxusercontent.com/u/4585325/AndroidLinkerProblem.zip

The code in the BPL looks like this:

extern "C"
{
#ifdef MSWINDOWS
   __declspec(dllexport) __stdcall
#endif
   int  Foo( int i )
   {
	   std::wstring string = L"";
	   TMemoryStream *stream = new TMemoryStream();
	   delete stream;
 
	   return i * 2;
   }
}


And then I invoke from Delphi, like this:

{$ifdef MSWINDOWS}
   function Foo( i : integer ) : integer; stdcall; external 'Package1.bpl';
{$elseif defined(ANDROID)}
   // file libPackage1.so renamed to a.so because compiler error "cannot find -lPackage1" !!!
   function Foo( i : integer ) : integer; cdecl; external 'a.so' dependency 'gnustl_static';   //'stdc++';   //'c++';
{$endif}


Please, can anyone help me?

Regards,
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Delphi Linker error
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 15, 2015 4:10 PM   in response to: Alejandro Rosa in response to: Alejandro Rosa
Should the Android version be dynamic? It usually does libraries via .SO files (SharedObjects).
Alejandro Rosa

Posts: 23
Registered: 10/30/09
Re: Delphi Linker error
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 17, 2015 5:54 AM   in response to: Eli M in response to: Eli M
Eli M wrote:
Should the Android version be dynamic? It usually does libraries via .SO files (SharedObjects).

I have already tried in dynamics libraries and have other problems:

dlopen fails with error "Can not load library: get_lib_extents [742]: 17031 - <PATH>/libPackage1.so is not a valid ELF object"


This error can not solve it, I have no idea if the project configuration problem, or missing dependencies.

I put in the forum a question about it more than a month ago, and never got answer:
https://forums.embarcadero.com/message.jspa?messageID=698817#698817
Alejandro Rosa

Posts: 23
Registered: 10/30/09
Re: Delphi Linker error
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 22, 2015 11:54 AM   in response to: Alejandro Rosa in response to: Alejandro Rosa
I've tested in iOS64 bits and works fine.

Remember, the problem is with Android, both static and dynamic use of the BPL created in C++, with an EXE in Delphi.

Can anybody help me?
Eray HANOGLU

Posts: 2
Registered: 2/26/08
Re: Delphi Linker error
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 24, 2016 6:48 AM   in response to: Alejandro Rosa in response to: Alejandro Rosa
Alejandro Rosa wrote:
I've tested in iOS64 bits and works fine.

Remember, the problem is with Android, both static and dynamic use of the BPL created in C++, with an EXE in Delphi.

Can anybody help me?

I got the same problem. Did you find a solution?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02