Author Topic: Compiling a PM sample with GCC (2023)  (Read 87884 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Compiling a PM sample with GCC (2023)
« on: April 22, 2023, 03:40:46 am »
Hi

I had setup a new Dev ArcaOS 5.0.7 VM to keep going with the "fun" of trying to compile some old Presentation Manager samples with GCC and other open source tools.

This is my Vanilla ArcaOS VM with:
- yum install git gcc make libc-devel binutils watcom-wrc watcom-wlink-hll

And I made sure that I have on the config.sys
 SET INCLUDE=C:\usr\include
 SET EMXOMFLD_LINKER=wl.exe
 SET EMXOMFLD_TYPE=WLINK
 
I'm very happy that the samples we checked before are now compiling and working.
- https://github.com/OS2World/DEV-SAMPLES-PM-PMWalker2
- https://github.com/OS2World/DEV-SAMPLES-PM-BitCat
- https://github.com/OS2World/DEV-SAMPLES-PM-PMHello

My new compile attempts, questions and cry for help come next.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #1 on: April 22, 2023, 03:43:34 am »
Hi

Now, I'm trying to compile VectFont
https://github.com/OS2World/DEV-SAMPLES-PM-VectFont

But checking the included makefile (VECTFONT) against the makefile I did, I'm not sure if missing some source code here.

I'm attaching my build attempt and the errors on make.out. I don't care about the warnings yet, just the errors to try to compile the sample as it is includes first and later go after the warnings.

Regards
« Last Edit: April 22, 2023, 01:14:17 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #2 on: April 22, 2023, 04:51:54 am »
Missing code? Look at VECTFONT and VECTFONT.LNK, seems there are various vf**.c files expected.

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #3 on: April 22, 2023, 09:28:38 am »
Hi

Now, I'm trying to compile VectFont
https://github.com/OS2World/DEV-SAMPLES-PM-VectFont

But checking the cnluded makefile (VECTFONT) against the makefile I did, I'm not sure if missing some source code here.

I'm attaching my build attempt and the errors on make.out. I don't care about the warnings yet, just the errors to try to compile the sample as it is includes first and later go after the warnings.

Regards

Martin, I seem to remember that the Petzold book builds one example upon the other. As Dave said, you will need to find the missing source files on the floppy disk (?) and add them to the GitHub repo.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #4 on: April 22, 2023, 12:28:52 pm »
Hi

I found the full version:
https://archive.org/download/OS2BBS/08-Other.zip/S12219.ZIP

Now I have to check out how to recreate the makefile with all those.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #5 on: April 22, 2023, 01:09:23 pm »
Hi

Now vf00 to vf15  are compiling with a lot of warnigs that I will check later.

I'm stuck here:

Code: [Select]
gcc -Zomf vectfont.obj vectfont.def -o vectfont.exe
weakld: error: Unresolved symbol (UNDEF) '_Display_CharAngle'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_24Point'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Stretch'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Block'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Mirror'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Rotate'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Spokes'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Shadow'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Hollow'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Neon'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_CharShear'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Fade'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_ModSpokes'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_DropShadow'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
weakld: error: Unresolved symbol (UNDEF) '_Display_Wavy'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldlF6kxQ.: line(19): protmode option not valid for an OS/2 EMX executable
Error! E2028: _Display_24Point is an undefined reference
Error! E2028: _Display_Mirror is an undefined reference
Error! E2028: _Display_Stretch is an undefined reference
Error! E2028: _Display_CharAngle is an undefined reference
Error! E2028: _Display_Rotate is an undefined reference
Error! E2028: _Display_CharShear is an undefined reference
Error! E2028: _Display_Shadow is an undefined reference
Error! E2028: _Display_Hollow is an undefined reference
Error! E2028: _Display_DropShadow is an undefined reference
Error! E2028: _Display_Block is an undefined reference
Error! E2028: _Display_Neon is an undefined reference
Error! E2028: _Display_Fade is an undefined reference
Error! E2028: _Display_Spokes is an undefined reference
Error! E2028: _Display_Wavy is an undefined reference
Error! E2028: _Display_ModSpokes is an undefined reference
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_24Point
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Mirror
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Stretch
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_CharAngle
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Rotate
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_CharShear
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Shadow
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Hollow
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_DropShadow
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Block
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Neon
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Fade
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Spokes
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_Wavy
file C:\dev\DEV-SAMPLES-PM-VectFont\vectfont.obj(vectfont.obj): undefined symbol _Display_ModSpokes
make: *** [vectfont.exe] Error 1


Maybe I'm not doing something fine on the new makefile. (nake,out attached)

Regards
« Last Edit: April 22, 2023, 01:12:12 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #6 on: April 22, 2023, 02:02:33 pm »
Hi

Checking my makefile I think I need to call all the .obj to create vectfont.exe.

I changed to this:
Quote
vectfont.exe : vectfont.obj vectfont.res vf00.obj vf01.obj vf02.obj vf03.obj vf04.obj vf05.obj vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj vf11.obj vf12.obj vf13.obj vf14.obj vf15.obj vectfont.def
   gcc -Zomf vectfont.obj vf00.obj vf01.obj vf02.obj vf03.obj vf04.obj vf05.obj vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj vf11.obj vf12.obj vf13.obj vf14.obj vf15.obj vectfont.def -o vectfont.exe
   wrc vectfont.res

Now the error changed to:

Code: [Select]
gcc -Zomf vectfont.obj vf00.obj vf01.obj vf02.obj vf03.obj vf04.obj vf05.obj vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj vf11.obj vf12.obj vf13.obj vf14.obj vf15.obj vectfont.def -o vectfont.exe
weakld: error: Unresolved symbol (UNDEF) '_max'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj
    C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj
weakld: error: Unresolved symbol (UNDEF) '_min'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj
    C:\dev\DEV-SAMPLES-PM-VectFont\vf05.obj
    C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldgVmPcu.: line(35): protmode option not valid for an OS/2 EMX executable
Error! E2028: _max is an undefined reference
Error! E2028: _min is an undefined reference
file C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj(vf00.obj): undefined symbol _max
file C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj(vf00.obj): undefined symbol _min
file C:\dev\DEV-SAMPLES-PM-VectFont\vf05.obj(vf05.obj): undefined symbol _min
file C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj(vf14.obj): undefined symbol _min
file C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj(vf14.obj): undefined symbol _max
make: *** [vectfont.exe] Error 1
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #7 on: April 25, 2023, 05:26:53 am »
os2tk45\h\libc\stdlib.h has,
Code: [Select]
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #8 on: April 25, 2023, 06:24:38 pm »
Hi  Dave

I haven't installed the OS2tk45.

I'm using this one:
Quote
[C:\usr\include]dir stdlib.h

The volume label in drive C is ARCAOS.
The Volume Serial Number is C470:B5BB.
Directory of C:\usr\include

 4-22-23  7:24a        16,886    124 a---  stdlib.h
        1 file(s)      16,886 bytes used

It does not has any max(a,b) or min(a,b). If I include those lines on stdlib.h I get the same error.

Code: [Select]
gcc -I. -Zomf vectfont.obj vf00.obj vf01.obj vf02.obj vf03.obj vf04.obj vf05.obj
 vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj vf11.obj vf12.obj vf13.obj vf14.ob
j vf15.obj vectfont.def -o vectfont.exe
weakld: error: Unresolved symbol (UNDEF) '_max'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj
    C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj
weakld: error: Unresolved symbol (UNDEF) '_min'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj
    C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldmdI0AW.: line(35): protmode option not valid for an OS/2
EMX executable
Error! E2028: _max is an undefined reference
Error! E2028: _min is an undefined reference
file C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj(vf00.obj): undefined symbol _max
file C:\dev\DEV-SAMPLES-PM-VectFont\vf00.obj(vf00.obj): undefined symbol _min
file C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj(vf14.obj): undefined symbol _min
file C:\dev\DEV-SAMPLES-PM-VectFont\vf14.obj(vf14.obj): undefined symbol _max
make: *** [vectfont.exe] Error 1


Now, I installed os2tk45, but I can not find stdlib.h to compare it with the one on "C:\usr\include".
Which package contains the os2tk45 stdlib.h ?

Regards
« Last Edit: April 25, 2023, 06:45:36 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #9 on: April 26, 2023, 02:06:24 am »
I found libc/stddef.h in os2tk45, the complete package. I guess Bitwise didn't add the conflicting libc to the rpm.
Simplest in this case is just to add the defines, with guards incase someone does use the toolkit or such where min and max are defined. VECTFONT.H seems like a good candidate, could create a header as well.
Code: [Select]
diff --git a/VECTFONT.H b/VECTFONT.H
index fcae64a..6fac9ca 100644
--- a/VECTFONT.H
+++ b/VECTFONT.H
@@ -48,3 +48,10 @@ VOID Display_Fade (HPS hps, LONG cxClient, LONG cyClient) ;
    // VF12
 VOID Display_Spokes (HPS hps, LONG cxClient, LONG cyClient) ;    // VF13
 VOID Display_Wavy (HPS hps, LONG cxClient, LONG cyClient) ;      // VF14
 VOID Display_ModSpokes (HPS hps, LONG cxClient, LONG cyClient) ; // VF15
+
+#ifndef max
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+#ifndef min
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#endif

This compiles but doesn't work as expected. Wrong max and min?
BTW, my makefile patch is this, more readable. I see you didn't commit the makefile :)
Code: [Select]
all : vectfont.exe

vectfont.exe : vectfont.obj vectfont.res vf00.obj vf01.obj vf02.obj vf03.obj \
            vf04.obj vf05.obj vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj \
            vf11.obj vf12.obj vf13.obj vf14.obj vf15.obj vectfont.def
        gcc -Zomf vectfont.obj vf00.obj vf01.obj vf02.obj vf03.obj vf04.obj \
            vf05.obj vf06.obj vf07.obj vf08.obj vf09.obj vf10.obj vf11.obj \
            vf12.obj vf13.obj vf14.obj vf15.obj vectfont.def -o vectfont.exe
        wrc vectfont.res

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #10 on: April 26, 2023, 05:07:46 am »
Hi

Sorry, no answers to the above questions but they do cause me to ask: Why can I not see the text in the boxes marked as Code: [Select] using Daves current Dooble build? - see attached dooble_text.jpg


Regards

Pete

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #11 on: April 26, 2023, 05:30:42 am »
Bad font? What does "fc-match fixed" output? Could try "fc-match -v fixed | less" for more info on the font.
Long term I'd suggest installing some more fonts.
Edit: Also try closing Dooble, run "fc-cache -r", wait till it finishes and try Dooble again
Edit2: Did you install WinOS2 support?
« Last Edit: April 26, 2023, 05:37:57 am by Dave Yeo »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #12 on: April 26, 2023, 05:50:29 am »
Hi Dave

In my case the program compiled, with your suggested change to vectfont.h. The exe file seems to be working, it is showing different text with different styles, like the origina sample exe.

I'm attaching it.

My next step will be to go after the warnings.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #13 on: April 26, 2023, 06:14:21 am »
OK, it looks like you fixed a few warnings and you're tree works here. Previous didn't show any of the different text's, just a blank window.
Edit: Seems that your changing a couple of USHORT's to ULONG's in VECTFONT.C fixed it.
Code: [Select]
@@ -7,13 +7,13 @@
 #include <os2.h>
 #include "vectfont.h"
 
-MRESULT EXPENTRY ClientWndProc (HWND, USHORT, MPARAM, MPARAM) ;
+MRESULT EXPENTRY ClientWndProc (HWND, ULONG, MPARAM, MPARAM) ;
 
 HAB hab ;
...
Code: [Select]
     WinDestroyWindow (hwndFrame) ;
@@ -46,7 +45,7 @@
      return 0 ;
      }
 
-MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1,
+MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1,
                                                        MPARAM mp2)
      {
      static struct {
« Last Edit: April 26, 2023, 06:29:50 am by Dave Yeo »

Pete

  • Hero Member
  • *****
  • Posts: 1281
  • Karma: +9/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #14 on: April 26, 2023, 06:24:59 am »
Hi Dave

[L:\]fc-match fixed
HELV.PFB: "Helvetica" "Regular"

fc-cache -r seems to have fixed the problem.


Thanks

Pete