Sign in Join

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

Mailing lists / fpc-pascal / 2022-08

Teaching Kids Using Free Pascal

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Anthony Walter

Some of you might not be aware, but I teach small groups of kids ages 8-16 computer programming and digital electronics. When teaching programming I often use Free Pascal and Lazarus, and try to come up with exciting ideas.

Over the past few weeks, I've taught my high school kids who have completed Algebra I programming using Linear Algebra. To help illustrate vectors, and matrices, I wrote a small program using Free Pascal to help them understand the sin(a) function.

I thought I'd share the result:

https://streamable.com/b5ojtt

If anyone wants to help the cause of teaching kids programming with Free Pascal, I am still offering a reward of $100 for a solution to the problem of static linking libraries on Windows (see my last message on that subject). Although I and the kids I teach use Linux in our lab sessions, I'd like to make it easier for Windows users to work with the toolkit I continue to develop,

Thank you for your time.
Anthony

Reply by email

Michael Van Canneyt
to Anthony Walter
Anthony Walter wrote 12 lines
Some of you might not be aware, but I teach small groups of kids ages 8-16 computer programming and digital electronics. When teaching programming I often use Free Pascal and Lazarus, and try to come up with exciting ideas. Over the past few weeks, I've taught my high school kids who have completed Algebra I programming using Linear Algebra. To help illustrate vectors, and matrices, I wrote a small program using Free Pascal to help them understand the sin(a) function. I thought I'd share the result: https://streamable.com/b5ojtt

A nice result, thank you for sharing this.

I talked to the chairman of the Free Pascal & Lazarus foundation and showed your mail.

The subject of teaching kids how to program in Pascal and in particular using it for math problems is something that is close to his heart (and to mine, as this is exactly how I rolled into Free Pascal a quarter of a century ago).

He is also the editor of the Blaise Pascal magazine, and has published a book by a dutch author that combines exactly these subjects:

https://www.blaisepascalmagazine.eu/product/books-computer-graphics-math-games-download-pdf/

I explained him your problem, and he agreed that the foundation should assist in trying to solve this problem.

Therefore, for all:

If someone presents a solution that can be distributed with the compiler & FPC which solves or considerably eases the problem (for instance a glue unit that can be included to provide most of the missing symbols, some compiler routines that aid...), the foundation will add another $200 to the bounty offered by Anthony Walter, subject to his and our approval.

Michael.

Reply by email

Thomas Kurz
to Michael Van Canneyt

I currently have only a few missing symbols, mostly math related:

Hint: (11030) Start of reading config file P:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg Hint: (11031) End of reading config file P:\Lazarus\fpc\3.2.2\bin\x86_64-win64\fpc.cfg Warning: (11018) You are using the obsolete switch -St Hint: (11030) Start of reading config file X:\Settings\Lazarus\fpcext.cfg Hint: (11031) End of reading config file X:\Settings\Lazarus\fpcext.cfg Free Pascal Compiler version 3.2.2 [2022/01/02] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others (1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(9015) Linking Z:\project1.exe
Z:\project1.lpr(11,1) Error: Undefined symbol: sin Z:\project1.lpr(11,1) Error: Undefined symbol: cos Z:\project1.lpr(11,1) Error: Undefined symbol: __imp___acrt_iob_func Z:\project1.lpr(11,1) Error: Undefined symbol: sqrt Z:\project1.lpr(11,1) Error: Undefined symbol: pow Z:\project1.lpr(11,1) Error: Undefined symbol: floor Z:\project1.lpr(11,1) Fatal: (10026) There were 6 errors compiling module, stopping Fatal: (1018) Compilation aborted
Error: P:\Lazarus\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode

The most tricky one seens to be "__imp___acrt_iob_func". A google search indicated that this one apparently is "hard-coded into the Go linker".

So my questions are:

- Has libchipmunk-win.a been compiled with Go? (I know that in your original message, you wrote about C, but I just want to be sure.)
- Have you tried using the Go linker instead of FPCs one?

But I will stay with it.

Earlier message 49 lines
----- Original Message ----- From: Michael Van Canneyt via fpc-pascal To: Anthony Walter via fpc-pascal Sent: Saturday, August 27, 2022, 11:14:55 Subject: [fpc-pascal] Teaching Kids Using Free Pascal On Sat, 27 Aug 2022, Anthony Walter via fpc-pascal wrote: > Some of you might not be aware, but I teach small groups of kids ages 8-16 > computer programming and digital electronics. When teaching programming I > often use Free Pascal and Lazarus, and try to come up with exciting ideas. > Over the past few weeks, I've taught my high school kids who have completed > Algebra I programming using Linear Algebra. To help illustrate vectors, > and matrices, I wrote a small program using Free Pascal to help them > understand the sin(a) function. > I thought I'd share the result: > https://streamable.com/b5ojtt A nice result, thank you for sharing this. I talked to the chairman of the Free Pascal & Lazarus foundation and showed your mail. The subject of teaching kids how to program in Pascal and in particular using it for math problems is something that is close to his heart (and to mine, as this is exactly how I rolled into Free Pascal a quarter of a century ago). He is also the editor of the Blaise Pascal magazine, and has published a book by a dutch author that combines exactly these subjects: https://www.blaisepascalmagazine.eu/product/books-computer-graphics-math-games-download-pdf/ I explained him your problem, and he agreed that the foundation should assist in trying to solve this problem. Therefore, for all: If someone presents a solution that can be distributed with the compiler & FPC which solves or considerably eases the problem (for instance a glue unit that can be included to provide most of the missing symbols, some compiler routines that aid...), the foundation will add another $200 to the bounty offered by Anthony Walter, subject to his and our approval. Michael.

Reply by email

Anthony Walter
to Thomas Kurz

Thomas,

Chimpmunk2D is written in C and I compiled it on Windows using three different compilers, each in an attempt to resolve the problem. I used mingw64 gcc with Linux cross compile, Windows Cygwin, and Windows Msys2. All fail for various reasons.

Regarding your missing __imp___acrt_iob_func, you can resolve individual missing dependencies by providing them yourself using the 'alias' feature of Free Pascal. This should at least resolve the dependency:

function acrt_iob_func: Pointer; cdecl; [ public, alias:
'__imp___acrt_iob_func'];
begin
  Result := nil;
end;

According to this stack overflow, the actual implementation should return a pointer to an array of three HFILE items somewhat like FILE _iob[] = {*stdin, *stdout, *stderr}; You can see if it can compile / link by using my implementation above. In the situations where I was able to widdle down the dependencis to to one or tow, this trick worked, but unfortunately after that I would get an internal linker error. Even in cases where I resolved all dependencies without the trick I still eventually end up with an internal linker error.

https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2

Finally, I also wrote a utility to search for missing dependencies on Windows.

https://cache.getlazarus.org/images/desktop/raylib-static.png

Henery Vermaak offered a similar solution for use at the command line.

(begin quote)

Note for anyone with msys2, you can make a file containing all defined external symbols like this (using atexit as an example):

find /mingw64/lib -name "*.a" -exec nm -pogC --defined-only '{}' \; 2> /dev/null > symbs.txt

Then search it with grep:

grep -w atexit symbs.txt

Resulting in:

C:/msys64/mingw64/lib/libmsvcr120.a:libmsvcr120_defs01591.o:0000000000000000 T atexit
C:/msys64/mingw64/lib/libmsvcr120_app.a:libmsvcr120_app_defs01268.o:0000000000000000T atexit
C:/msys64/mingw64/lib/libmsvcr120d.a:libmsvcr120d_defs01654.o:0000000000000000 T atexit

(end quote)

Reply by email