Recent

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

jmpessoa

  • Hero Member
  • *****
  • Posts: 2312
About Free Pascal and MinGW (or cygwin)
« on: June 04, 2013, 05:26:35 am »
Hi there!

I learned that the android-ndk can produce/compile native library 
write in "C" "binding" against MinGW (or cygwin) stuff on Windows environment...

Anyone know about the possibility of Free Pascal "binding" against MinGW(or cygwin) stuff on Windows to produce
Linux library?

I found this:

ftp://ftp.freepascal.org/pub/fpc/contrib/cross/mingw/

Is it about this subject?

Thanks in advance ..
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #1 on: June 05, 2013, 10:01:26 am »
One can generate linux binaries on Windows. This is what crosscompiling does.

Generally on windows, one uses crossassemblers, archivers and linkers from mingw sources.  The rest is not really necessary. (in rare cases also windres).

Just search for crosscompiling topics on this forum.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2312
Re: About Free Pascal and MinGW (or cygwin)
« Reply #2 on: June 05, 2013, 05:11:33 pm »
Very thank Marcov!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #3 on: July 01, 2024, 11:41:25 am »
i use this release with full posix thread support and compatible .dll generation, other version are incompatible in terms of .dll headers or do not support std::threads

g++  -std=c++11 -pthread -static -shared -O3 -o yourdll.dll source_cpp_files.cpp

https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-posix/sjlj/x64-4.8.1-release-posix-sjlj-rev5.7z/download


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #4 on: July 01, 2024, 11:44:45 am »
Note that FPC on Windows is SEH not SJLJ, though for the 32-bit version that is relatively recent (3.2.0)

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #5 on: July 01, 2024, 06:52:13 pm »
moved to the seh version @ https://sourceforge.net/projects/mingwbuilds/

so what's the recommended MinGw version & location, currently using gcc version 4.8.1 ?

current 3.4 version uses GNU ld (GNU Binutils) 2.23.2, so should mingw version be compatible?


I've also tried to generate a .dll w/visual studio 2022 with no success (import library not found), is this possible?
« Last Edit: July 01, 2024, 06:57:10 pm by rforcen »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #6 on: July 01, 2024, 07:38:35 pm »
The recommend utils come with FPC.

But for building DLLs to be used with FPC, SEH is probably best.

I compile my C/C++ code with Visual Studio though, so I wouldn't know what  mingw to use currently

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #7 on: July 02, 2024, 09:11:23 am »
i get "import library not found" when replacing .dll generated by minGW with VS2022 one

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #8 on: July 02, 2024, 01:49:00 pm »
Huh? Free Pascal usually doesn't need import libs.

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #9 on: July 02, 2024, 01:57:09 pm »
Yes, the mingw versión doesn't need It, I use {$linklib} not LoadLibrary('module.DLL')

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #10 on: July 02, 2024, 02:03:50 pm »
Yes, the mingw versión doesn't need It, I use {$linklib} not LoadLibrary('module.DLL')

$linklib is for static libraries (.a).

For .dll, just name them in your declarations

Code: Pascal  [Select][+][-]
  1. function xx(parameters):resulttype; stdcall; external 'bla.dll'  name 'myxx';

you can use a constant e.g. 

Code: Pascal  [Select][+][-]
  1. const kernel32dll='kernel32.dll';

Zvoni

  • Hero Member
  • *****
  • Posts: 2620
Re: About Free Pascal and MinGW (or cygwin)
« Reply #11 on: July 02, 2024, 02:07:18 pm »
Yes, the mingw versión doesn't need It, I use {$linklib} not LoadLibrary('module.DLL')

$linklib is for static libraries (.a).

For .dll, just name them in your declarations

Code: Pascal  [Select][+][-]
  1. function xx(parameters):resulttype; stdcall; external 'bla.dll'  name 'myxx';

you can use a constant e.g. 

Code: Pascal  [Select][+][-]
  1. const kernel32dll='kernel32.dll';

From here: https://forum.lazarus.freepascal.org/index.php/topic,66610.0.html
Quote
In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

In any case, your Declarations are as follows:

Function SomeFunction(SomeArguments):SomeReturnType;call_convention;external; --> NO LIBNAME!!
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11729
  • FPC developer.
Re: About Free Pascal and MinGW (or cygwin)
« Reply #12 on: July 02, 2024, 03:32:35 pm »
That is not about DLL, but static libraries.

Zvoni

  • Hero Member
  • *****
  • Posts: 2620
Re: About Free Pascal and MinGW (or cygwin)
« Reply #13 on: July 02, 2024, 04:29:25 pm »
That is not about DLL, but static libraries.
You sure? TS is talking about trying to generate a dll, but uses linklib
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

rforcen

  • Jr. Member
  • **
  • Posts: 52
Re: About Free Pascal and MinGW (or cygwin)
« Reply #14 on: July 02, 2024, 04:35:03 pm »
Yes, the mingw versión doesn't need It, I use {$linklib} not LoadLibrary('module.DLL')

$linklib is for static libraries (.a).

For .dll, just name them in your declarations

Code: Pascal  [Select][+][-]
  1. function xx(parameters):resulttype; stdcall; external 'bla.dll'  name 'myxx';

you can use a constant e.g. 

Code: Pascal  [Select][+][-]
  1. const kernel32dll='kernel32.dll';

From here: https://forum.lazarus.freepascal.org/index.php/topic,66610.0.html
Quote
In a nutshell:
{$LinkLib LIBNAME} --> you need the LIBNAME.a file
{$Link LIBNAME} --> you need the LIBNAME.o file

In any case, your Declarations are as follows:

Function SomeFunction(SomeArguments):SomeReturnType;call_convention;external; --> NO LIBNAME!!

you can link dynamic libs with {$linklib dl.dll} / win in all os {$linklib dl.so} / linux {$linklib dl.dylib} / macos
the problem i'm addressing is some compilers/versions are not compatible

 

TinyPortal © 2005-2018