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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #45 on: April 12, 2022, 04:37:44 pm »
Hi Martin, the PROTMODE statement is for whether the program runs in real or protected mode, which doesn't make sense for 32 bit OS/2 but is silently ignored by the IBM linkers, best is to simply remove it.
The program is weird, maybe written for OS/2 1.1? I got it to show up in the window list with this patch. At least now it is easy to kill :)
Code: [Select]
H:\tmp\boxes>diff -u BOXES3.C.orig BOXES3.C
--- BOXES3.C.orig       2022-04-11 21:08:42.000000000 -0700
+++ BOXES3.C    2022-04-11 21:17:24.000000000 -0700
@@ -25,8 +25,7 @@
      QMSG        qmsg ;

      ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
-                      FCF_MINMAX | FCF_TASKLIST | FCF_ICON | FCF_ACCELTABLE |
-                      FCF_MENU;
+                      FCF_MINMAX | FCF_TASKLIST;
      const unsigned char szTitle [] = "Boxes";

      hab = WinInitialize (0) ;
@@ -41,18 +40,13 @@

      hwndFrame = WinCreateStdWindow (
                     HWND_DESKTOP,       /* Parent window handle            */
-                    WS_VISIBLE          /* Style of frame window           */
-                         | FS_SIZEBORDER
-                         //| WC_TITLEBAR
-                         | FID_SYSMENU
-                         | FID_MINMAX
-                         | VK_MENU,
+                    WS_VISIBLE,          /* Style of frame window           */
                     &flFrameFlags,      /* Client window class name        */
                     szClientClass,      /* Title bar text                  */
-                    szTitle,
+                    NULL,
+                    0L,
                     0,                 /* Style of client window          */
                     0,                 /* Module handle for resources     */
-                    ID_MAINMENU,        /* ID of resources                 */
                     &hwndClient) ;      /* Pointer to client window handle */

      while (WinGetMsg (hab, &qmsg, 0, 0, 0))

Looking at the msg queue, instead of the usual CASE WM_CREATE, it starts with CASE WM_COMMAND. Probably the whole queue thing needs to be rewritten, which I'm not knowledgeable enough to do. Need to find my OS/2 programming for Dummies book :)
Perhaps someone with more knowledge can chime in.

Thanks Dave. I made the suggested changes and now it shows on the window list, but yes, it does not display anything. I will let it here rest until maybe someone can give us a hint.

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #46 on: April 12, 2022, 05:17:43 pm »
Hi

I also compiled this PMHELLO samples.  I cleaned up the warnings, it compiles, it works and displays the PM Sample.

I only have this warning.
Code: [Select]
gcc -Wall -Zomf -c -O2 pmhello.c -o pmhello.obj
gcc -Wall -Zomf -c -O2 pmhello1.c -o pmhello1.obj
gcc -Zomf pmhello.obj pmhello1.obj pmhello.def -o pmhello1.exe
E:\projects\SamplePack\dev-samples-pm-pmhello\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
gcc -Wall -Zomf -c -O2 pmhello2.c -o pmhello2.obj
gcc -Zomf pmhello.obj pmhello2.obj pmhello.def -o pmhello2.exe
E:\projects\SamplePack\dev-samples-pm-pmhello\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
gcc -Wall -Zomf -c -O2 pmhello3.c -o pmhello3.obj
gcc -Zomf pmhello.obj pmhello3.obj pmhello.def -o pmhello3.exe
E:\projects\SamplePack\dev-samples-pm-pmhello\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
I guess it shows since I removed PROTMODE from the .DEF file.  Any tips to remove that warning?

Regards




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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #47 on: April 12, 2022, 05:30:18 pm »
Hi

Just as a note to myself and any comments are welcome.

I created a new development VM with ArcaOS 5.0.7 just with the goal to compile my samples, since my other VM had a lot of other dev software that I was not using with some the stuff on the config.sys. I wanted to started clean.

To recover my status of being able to compile these samples I did:
1) yum install gcc libc-devel binutils kbuild-make
2) SET INCLUDE=C:\usr\include; on Config.sys
3) Got "ilink50.zip" and put the exe on C:\sys\bin and DLLs on c:\sys\dll
(I guess there is no ilink on the rpm)

With that I have the basic stuff to compile the samples again.

Regards
never do 2)

Yes, right, I don't know what happened earlier that I got an error that can not find OS2.H. But now I had removed the SET INCLUDE on the config.sys and it keeps working.

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #48 on: April 12, 2022, 05:39:45 pm »
3) use wlink instead of ilink. there is a wlink and wrc rpm.

Hi

I would prefer to use wlink since (I guess) it is open source. But I have no idea if how to call it, since on the makefile I'm not making a direct link to "Ilink", I don't know if gcc is the one calling it.

Any suggestion what to change on the makefile to call wlink and give it a try with these samples?

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #49 on: April 12, 2022, 05:53:10 pm »
3) use wlink instead of ilink. there is a wlink and wrc rpm.

Hi

I would prefer to use wlink since (I guess) it is open source. But I have no idea if how to call it, since on the makefile I'm not making a direct link to "Ilink", I don't know if gcc is the one calling it.

Any suggestion what to change on the makefile to call wlink and give it a try with these samples?

Regards

Run emxomfld with no arguments to see how to call the various linkers and rc's.

Silvan Scherrer

  • Full Member
  • ***
  • Posts: 204
  • Karma: +1/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #50 on: April 12, 2022, 06:23:38 pm »
3) use wlink instead of ilink. there is a wlink and wrc rpm.

Hi

I would prefer to use wlink since (I guess) it is open source. But I have no idea if how to call it, since on the makefile I'm not making a direct link to "Ilink", I don't know if gcc is the one calling it.

Any suggestion what to change on the makefile to call wlink and give it a try with these samples?

Regards
if you install it via rpm all gets set up for you. gcc then finds the right linker.
kind regards
Silvan
CTO bww bitwise works GmbH

Please help us with donations, so we can further work on OS/2 based projects. Our Shop is at https://www.bitwiseworks.com/shop/index.php

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #51 on: April 12, 2022, 07:15:03 pm »
Hi

I installed "watcom-wrc" package and I don't know what happened to the envirment.

I get:
Quote
Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef C:\OS2\RCPP.ERR
fatal error C1015: cannot open include file 'os2.h'
make: *** [walker.res] Error 3

and with wrc the same error:
Code: [Select]
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
wrc -r walker.rc
Open Watcom Windows and OS/2 Resource Compiler Version 2.0beta1 LA
Portions Copyright (c) 1993-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
walker.rc(2): Error! E062:  Unable to open 'os2.h'
make: *** [walker.res] Error 9

Regards

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #52 on: April 13, 2022, 02:02:15 am »
That's weird as the wrc package only has wrc.exe and some type of documentation.
Try reinstalling GCC and libc-devel?

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #53 on: April 13, 2022, 04:27:22 am »
Hi

I tried again to refresh the VM. 
I had only installed "yum install gcc libc-devel binutils kbuild-make" and ilink5.0.zip, no "watcom-wrc" yet.

Now I get this new error from RC.

Code: [Select]
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
gcc -Zomf walker.obj walker.def -o walker.exe
E:\projects\SamplePack\PMwalker_r4\walker.def(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
rc walker.res
Operating System/2 Resource Compiler
Version 4.00.011 Oct 10 2000
(C) Copyright IBM Corporation 1988-2000
(C) Copyright Microsoft Corp. 1985-2000
All rights reserved.


Reading binary resource file walker.res


(0) RC: error - Only integer TYPE allowed ().
RC: 1 error detected

make: *** [walker.exe] Error 1

It compiles and create the exe, but the icon is not assigned and if you run the exe it does not shows anything.

My second question is, where is wlink.exe? I can not find it on the RPM.

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #54 on: April 13, 2022, 05:40:18 am »
That seems like a weird error. Wonder if it is due to the wrong ilink? There's 2 or 3 of them and they all like slightly different syntax. Default is the ilink from VAC365 with ilink 5 only licensed for building Mozilla but IIRC, it is more compatible with the VAC365 one.
The warning about WINDOWCOMPAT seems weird too, at least my version of walker.def has WINDOWAPI.
The RPM package name is watcom-wlink-hll, see if that fixes things.
BTW, I usually stick to rc.exe rather then wrc.exe as it seems I've had problems with them not quite being compatible.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #55 on: April 13, 2022, 05:46:52 am »
Tested wrc by editing the makefile, compiles fine.
Code: [Select]
gcc -Zomf -c -O2 walker.c -o walker.obj
gcc -Zomf walker.obj walker.def -o walker.exe
wrc walker.res
Open Watcom Windows and OS/2 Resource Compiler Version 2.0beta1 LA
Portions Copyright (c) 1993-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #56 on: April 17, 2022, 02:10:46 am »
Hi

I still get the OS2.h issue, no idea what to do:

Code: [Select]
[E:\PROJECTS\SAMPLEPACK\PMWALKER]make   2>&1  | tee make.out
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
wrc -r walker.rc
Open Watcom Windows and OS/2 Resource Compiler Version 2.0beta1 LA
Portions Copyright (c) 1993-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
walker.rc(2): Error! E062:  Unable to open 'os2.h'
make: *** [walker.res] Error 9


But I have some other questions:
- Where is wlink? I can not find it on the rpm, is it there? I need the package name if it is there.
- Did you change something special on the makefile to use wrc? 
  I just changed the make file to:
Code: [Select]
all : walker.exe

walker.exe : walker.obj walker.res walker.def
gcc -Zomf walker.obj walker.def -o walker.exe
wrc walker.res

walker.obj : walker.c walker.h
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj

walker.res : walker.rc step1.ico step2.ico step3.ico
wrc -r walker.rc

clean :
rm -rf *exe *RES *obj

But I still need to know what is the issue with the OS2.H. I only have this one:
Quote
Directory of C:\usr\include

 4-16-22  6:16p           721    124 a---  os2.h


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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #57 on: April 17, 2022, 06:54:35 am »
Hi

I still get the OS2.h issue, no idea what to do:

Code: [Select]
[E:\PROJECTS\SAMPLEPACK\PMWALKER]make   2>&1  | tee make.out
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
wrc -r walker.rc
Open Watcom Windows and OS/2 Resource Compiler Version 2.0beta1 LA
Portions Copyright (c) 1993-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
walker.rc(2): Error! E062:  Unable to open 'os2.h'
make: *** [walker.res] Error 9


But I have some other questions:
- Where is wlink? I can not find it on the rpm, is it there? I need the package name if it is there.

As I said, watcom-wlink-hll is the package name

Quote

- Did you change something special on the makefile to use wrc? 
  I just changed the make file to:
Code: [Select]
all : walker.exe

walker.exe : walker.obj walker.res walker.def
gcc -Zomf walker.obj walker.def -o walker.exe
wrc walker.res

walker.obj : walker.c walker.h
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj

walker.res : walker.rc step1.ico step2.ico step3.ico
wrc -r walker.rc

clean :
rm -rf *exe *RES *obj

Yes that is what I did
Quote
But I still need to know what is the issue with the OS2.H. I only have this one:
Quote
Directory of C:\usr\include

 4-16-22  6:16p           721    124 a---  os2.h


Regards

All mine seem to be 723 bytes in size, try reinstalling

Code: [Select]
[W:\usr\include]dir os2.h

The volume label in drive W is ARCAOS.
The Volume Serial Number is 2D68:FC15.
Directory of W:\usr\include

 8-26-21  7:26a           723    124 a---  os2.h
        1 file(s)         723 bytes used
                    293,700,608 bytes free
« Last Edit: April 17, 2022, 06:56:25 am by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5033
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #58 on: April 17, 2022, 06:58:14 am »
Here's my os2.h,
Code: [Select]
/* os2.h,v 1.3 2004/09/14 22:27:35 bird Exp */
/** @file
 * EMX
 */

#ifndef NO_INCL_SAFE_HIMEM_WRAPPERS
# include <os2safe.h>
#endif

#ifndef _OS2_H
#define _OS2_H

#if defined (__cplusplus)
extern "C" {
#endif

#ifndef _Cdecl
#define _Cdecl
#endif
#ifndef _Far16
#define _Far16
#endif
#ifndef _Optlink
#define _Optlink
#endif
#ifndef _Pascal
#define _Pascal
#endif
#ifndef _Seg16
#define _Seg16
#endif
#ifndef _System
#define _System
#endif

#if defined (USE_OS2_TOOLKIT_HEADERS)
#include <os2tk.h>
#else
#include <os2emx.h>          /* <-- change this line to use Toolkit headers */
#endif
#include <os2thunk.h>

#if defined (__cplusplus)
}
#endif

#endif /* not _OS2_H */

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4992
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #59 on: June 29, 2022, 01:30:15 am »
Hi

I got some time today and I wanted to keep compiling some little PM samples. I had restarted my test with "PMHELLO".

My Dev enviroment is back in business and I was able to compile the sample with these warnings.

Code: [Select]
gcc -Wall -Zomf -c -O2 pmhello.c -o pmhello.obj
gcc -Wall -Zomf -c -O2 pmhello1.c -o pmhello1.obj
gcc -Zomf pmhello.obj pmhello1.obj pmhello.def -o pmhello1.exe
E:\projects\SamplePack\TEST\PM-PMHELLOb1\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
gcc -Wall -Zomf -c -O2 pmhello2.c -o pmhello2.obj
gcc -Zomf pmhello.obj pmhello2.obj pmhello.def -o pmhello2.exe
E:\projects\SamplePack\TEST\PM-PMHELLOb1\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI
gcc -Wall -Zomf -c -O2 pmhello3.c -o pmhello3.obj
gcc -Zomf pmhello.obj pmhello3.obj pmhello.def -o pmhello3.exe
E:\projects\SamplePack\TEST\PM-PMHELLOb1\PMHELLO.DEF(3) : warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI

Just as a reminder I'm using:
Quote
- ArcaOS   - Verion 5.0.7
- RC    - Version 4.00.011 Oct 10 2000
- gcc      - gcc (GCC) 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
- make    - Version 3.81 k2 (2017-11-10)
- ilinker     - Version 5.0

Is this warning related to the linker? or gcc?

Regards
« Last Edit: June 29, 2022, 01:33:43 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.