Sign in Join

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

Mailing lists / fpc-pascal / 2008-10

linklib c using mingw, cygwin, both, or ...

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Unknown author

I'm trying to follow the tutorial, How to use C code in FreePascal projects,

ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf

In order to get gcc running on Windows, I tried both options, mingw and cygwin. This or that way, compiling hello.c to hello.o works. Linking hello.o to hello.pas via {$linklib c} fails, when hello.o was created via mingw/gcc. FPC can't find libc.dll or libc.a, since mingw does not install it.

With cygwin's gcc, libc.a can be found straightforward, where I would expect it, in c:/cygwin/lib/. fpc compiles without warning, now windows needs cygwin1.dll. Done, as well, but my hello.exe still ends up with runtime error 216.

Any advice, another way around?

Thanks in advance
Wolfram

Wolfram Kläger
Show quoted text 5 lines
I'm trying to follow the tutorial, How to use C code in FreePascal projects, ftp://ftp.freepascal.org/pub/fpc/docs-pdf/CinFreePascal.pdf In order to get gcc running on Windows, I tried both options, mingw and cygwin. ...

Solved. Instead of

{$linklib c}

as described in the tutorial, read

http://community.freepascal.org:10000/bboards/message?message_id=268811&forum_id=24083

and give

{$linklib c:/mingw/lib/libmsvcrt.a}

a try. Instead of specifying the absolute path, add the following line to the library search path of your fpc.cfg

-Flc:/mingw/lib

or wherever your mingw installation resides. The tutorial mentions, other linking errors might occur or might not, if

{$link gcc}

is specified, or not. The earlier poster even had to add a

{$Linklib kernel32}

In my case, neither nor is required.

Wolfram

PS Maybe it's a good idea, providing Gilles Marcou's tutorial as a wiki instead of a PDF. At least me, I'd be happy to see continuous updates to such essentials and would not hesitate to do it by myself.