FPC internal linker issues with Win64 .a startic-link libraries by GCC newer than 4.8.1
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
-
Reporter name: Benjamin Rosseaux
Original Reporter info from Mantis: benjamin@0ok.de @bero1985
- Reporter name: Benjamin Rosseaux
Description:
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 without 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 bugtracker report. So someone, who are more inside the FreePascal source code structure, should finish this patch.
Steps to reproduce:
Try a current Win64 static-link libSDL2.a (from SDL2-devel-2.0.4-mingw.tar.gz on http://libsdl.org/download-2.0.php ) to a FPC-compiled project.
Additional information:
It seems to be Windows-only-specific, and possibly also Win64-only-specific.