Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-10

Unable to link static lib files on Window

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter

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 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?

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.

In the meanwhile, can someone please describe what are the usual causes of `unknown COFF magic`?

Reply by email

Sven Barth
to Anthony Walter
Anthony Walter wrote 24 lines
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.

Show quoted text 6 lines
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

Reply by email