Recent

Author Topic: About Free Pascal and MinGW (or cygwin)  (Read 8258 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 7483
Re: About Free Pascal and MinGW (or cygwin)
« Reply #15 on: July 03, 2024, 09:39:38 am »
I wonder whether I could throw in something belatedly: I expect to be fact-checked by Marco and if he says I'm wrong I'll delete this posting in case it causes further confusion.

Years and years ago, either FPC or Lazarus used some of the Cygwin functionality on Windows.

That is, as far as I know, thoroughly obsolete and any web pages that refer to it should be treated as suspect.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #16 on: July 03, 2024, 10:25:20 am »
Years and years ago, either FPC or Lazarus used some of the Cygwin functionality on Windows.

First cygwin, and then later mingw.  But that bit was the GDB debugger linked into the textmode IDE. There were some minor sideways related but reusable things like unit signals (ugh). It was never somewhere really deep in FPC itself.

Nowadays, on platforms that multitask, that has changed to working via pipes. Only single task systems like Dos still link GDB in.

As for standalone mingw/cygwin use, most of the binaries delivered with Windows releases are mingw, though in nearly all cases pretty old (and by that I mean near 20 years, because they are MSYS less versions). Only make is a bit newer due to parallel building becoming more important in the last decade(s).

Some are obsoleted or near obsoleted by "newer" FPC development like internal assembler (pre FPC 2.0), internal linker (2.2.0) and fpcres (3.2.2 is pretty capable, 3.2.4 will be even better, and when that version is out, it depends on the will to jump into the deep and make it default)


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #17 on: July 03, 2024, 10:29:07 am »
That is not about DLL, but static libraries.
You sure? TS is talking about trying to generate a dll, but uses linklib

And that is wrong for nearly everything not ancient (and by that I mean 20 if not 25 years +).

He references a thread that talks about static linking, but is himself talking about DLLs in the post that makes the reference which is not consistent.

I suspect he wants to link a library that he has in DLL form statically.  But that is quite an advanced topic.



MarkMLl

  • Hero Member
  • *****
  • Posts: 7483
Re: About Free Pascal and MinGW (or cygwin)
« Reply #18 on: July 03, 2024, 10:32:27 am »
First cygwin, and then later mingw.  But that bit was the GDB debugger linked into the textmode IDE. There were some minor sideways related but reusable things like unit signals (ugh). It was never somewhere really deep in FPC itself.

OK, TFT. So there's a risk that OP's been led astray by something he's found in a mailing list archive etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5644
  • Compiler Developer
Re: About Free Pascal and MinGW (or cygwin)
« Reply #19 on: July 07, 2024, 09:48:53 pm »
i get "import library not found" when replacing .dll generated by minGW with VS2022 one

FPC's internal linker does not support static or import libraries as generated by Visual Studio's linker. If you need them then you need to make sure the external linker using -Xe.

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: About Free Pascal and MinGW (or cygwin)
« Reply #20 on: July 07, 2024, 10:25:59 pm »
FPC's internal linker does not support static or import libraries as generated by Visual Studio's linker. If you need them then you need to make sure the external linker using -Xe.
Please clarify for me:

Is it possible to use an MS C produced obj or lib using the external linker ?

if the answer is yes, could you please elaborate and/or provide a simple example ?

Thank you.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5644
  • Compiler Developer
Re: About Free Pascal and MinGW (or cygwin)
« Reply #21 on: July 07, 2024, 10:32:56 pm »
FPC's internal linker does not support static or import libraries as generated by Visual Studio's linker. If you need them then you need to make sure the external linker using -Xe.
Please clarify for me:

Is it possible to use an MS C produced obj or lib using the external linker ?

if the answer is yes, could you please elaborate and/or provide a simple example ?

Simply use {$link ...} or {$linklib ...} like with any object file or library and pass -Xe when compiling, so that ld is used (which correctly supports the formats used by the Microsoft linker). Though for object files you can also use the internal linker as those are simply COFF object files. However static libraries have a slight difference in the header between the MSVC and GCC formats.

440bx

  • Hero Member
  • *****
  • Posts: 4478
Re: About Free Pascal and MinGW (or cygwin)
« Reply #22 on: July 08, 2024, 03:18:53 am »
For some reason I was under the impression that MS had departed enough from standard COFF object files to make them incompatible with them.  My misunderstanding.

Thank you for the clarification.  This is really good to know.



(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #23 on: July 08, 2024, 09:50:42 am »
in visual studio exported funcs MUST include prefix "__declspec(dllexport)  "

Code: C  [Select][+][-]
  1. extern "C" {
  2.     __declspec(dllexport) int foo(int a, int b) { return a+b; }
  3. }

in fpc as usual:

Code: Pascal  [Select][+][-]
  1. function foo(a,b:integer); cdecl; external;
« Last Edit: July 08, 2024, 10:12:23 am by rforcen »

 

TinyPortal © 2005-2018