Hello,

i've noticed a weakness of the FPC internal linker at static-linking .a
libraries on the Win64 target, which're generated by GCC newer than 4.8.1,
due to the new refptr.* and .refptr.* symbols-can-be-multiple-defined stuff
(inside one single .a library file), which was introduced in newer GCC
versions.

For example, when I do to want link SDL2 statically to my FPC code, where
the libSDL2.a as Win64 StaticLink Build was generated with GCC 4.9.1 or
newer, then FPC abort with a error and outputs:

> Free Pascal Compiler version 3.1.1 [2016/08/22] for x86_64
> Copyright (c) 1993-2016 by Florian Klaempfl and others
> Target OS: Win64 for x64
> Compiling racegame.dpr
> Linking racegame_x86_64.exe
> Error: Multiple defined symbol .refptr.SDL_free_REAL
> Error: Multiple defined symbol .refptr.SDL_XInputGetCapabilities
> Error: Multiple defined symbol .refptr.SDL_Appname
> Error: Multiple defined symbol .refptr.SDL_Instance
> Error: Multiple defined symbol .refptr.SYS_Joystick
> Error: Multiple defined symbol .refptr.SDL_XInputSetState
> Error: Multiple defined symbol .refptr.SDL_HelperWindow
> Error: Multiple defined symbol .refptr.GUID_XAxis
> Error: Multiple defined symbol .refptr.GUID_YAxis
> Error: Multiple defined symbol .refptr.GUID_ZAxis
> Error: Multiple defined symbol .refptr.GUID_RxAxis
> Error: Multiple defined symbol .refptr.GUID_RyAxis
> Error: Multiple defined symbol .refptr.GUID_RzAxis
> Error: Multiple defined symbol .refptr.IID_IDirectInput8W
> Error: Multiple defined symbol .refptr.CLSID_DirectInput8
> Error: Multiple defined symbol .refptr.SDL_hapticlist
> Error: Multiple defined symbol .refptr.IID_IDirectInputDevice8W
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Error: Multiple defined symbol .refptr.SDL_expand_byte
> Fatal: There were 25 errors compiling module, stopping
> Fatal: Compilation aborted

But for example, when I do to want the same, but where the libSDL2.a as
Win64 StaticLink Build was generated this time with GCC 4.8.1 or older,
then FPC links it with any error.

So I did some research on this issue and found
https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00858.html in the gcc-patches
mailing list and tp://
stackoverflow.com/questions/28012075/what-does-refptr-mean-in-a-mingw64-def-file
, so I've looked at ogbase.pas of FreePascal, and try to write a beginning
patch, which I've attached it to this mail. So someone, who are more inside
the FreePascal source code structure, should finish this patch.

Regards,
Benjamin 'BeRo' Rosseaux

Attachment: ogbase.pas.patch
Description: Binary data

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to