[fpc-pascal] Unable to link static lib files on Window

Sven Barth pascaldragon at googlemail.com
Tue Oct 26 22:19:05 CEST 2021


Am 25.10.2021 um 22:38 schrieb Anthony Walter via fpc-pascal:
> I know I was previously able to link static library files on Windows 
> with FPC, but hadn't used this feature in a while. When I recently 
> tried using static linking I am receiving error messages leaving me to 
> believe something has changed with the compiler.
>
> The error messages I receive all relate to `unknown COFF magic` found 
> in my files, and the builds fail at linking.
>
> I am using Mingw for Windows targeting an x86_64 to build static 
> libraries. If I link them to functions in my Pascal code using:
>
> {$linklib mystaticfile.a}
>
> I receive the error when trying to build. Also, if I try to link using 
> the Mingw static libraries with FPC I get the same message.  As 
> another option, I have also tried building static libraries on Windows 
> both using MSVC with everything set to compile as C code (vs C++), and 
> again using the MS C command line compiler (CL.EXE) and the same thing 
> happens.
>
> It's as if when using x86_64 static libraries, FPC always encounters 
> magic COFF errors and will not link. I am not sure what is going on. 
> When did FPC lose the ability to link static libraries with x86_64 
> architecture on Windows?

FPC never supported linking against static libraries generated in the 
*MSVC* format which is slightly different from what GCC/MinGW itself 
generates.

>
> I am using the most recent non-trunk revisions of FPC + Lazarus.
>
> If it helps I can follow up with post the C code, compiler /  linker 
> commands I am using to generate these static libraries, and binaries 
> of these libraries for anyone to test and research the problem.

Yes, please show the commands as I can't reproduce it with a simple example.

Regards,
Sven


More information about the fpc-pascal mailing list