OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Martin Iturbide on March 30, 2022, 12:06:44 am

Title: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 12:06:44 am
Hi

I'm trying to compile a little PM sample, just for the fun of it.

It is: PMWalker_r2.zip (https://hobbes.nmsu.edu/download/pub/os2/dev/samples/PM/PMWalker_r2.zip)
The make file uses gcc, link386 and rc.

I run nmake and it shows me this error:

Quote
{2}[e:\projects\samplepack\pmwalker_r2] nmake

Operating System/2 Program Maintenance Utility
Version 4.00.001 Oct  4 2001
Copyright (C) IBM Corporation 1988-2001
Copyright (C) Microsoft Corp. 1988-1991
All rights reserved.

        gcc -c -O2 walker.c
walker.c:30:10: fatal error: os2.h: No such file or directory
   30 | #include <os2.h>
      |          ^~~~~~~
compilation terminated.
NMAKE : fatal error U1077: 'C:\SYS\APPS\4OS2\4OS2.EXE' : return code '1'
Stop.

I have OS2.h on "C:\usr\include\os2tk45"  and on the config.sys "SET INCLUDE=C:\usr\include\os2tk45"

Any idea why I have that error? Do I have to use other OS2.h ?

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Lars on March 30, 2022, 01:03:17 am
gcc.exe does not know about INCLUDE env var. Try C_INCLUDE_PATH instead.

If that does not work , add -Ic:/usr/include/os2tk45 to the compiler commandline in the makefile.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 03:17:55 am
Actually, GCC wants the os2.h in @unixroot\usr\include and should find it on its own without C_INCLUDE_PATH or -I, if you want to use the one in the toolkit, you need to define USE_OS2_TOOLKIT_HEADERS 1 or edit os2.h around line 39. Should use the define though.
Likewise, if you need  Toolkit header like dive.h, the toolkit headers need to be at the end of the C include search path, C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45 or use -Idirafter=c:/usr/include/os2tk45.
Anyways, PMwalker seems to be designed for EMX, after editing the makefile to compile with kLIBC, I get,
Code: [Select]
        gcc -Zomf walker.obj walker.def
weakld: error: Unresolved symbol (UNDEF) '_ClientWndProc'.
weakld: info: The symbol is referenced by:
    H:/tmp/PMwalker/walker.def
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldZXONto.: line(20): protmode option not valid for an OS/2
EMX executable
Error! E2028: _ClientWndProc is an undefined reference
Error! E2044: exported symbol _ClientWndProc not found
NMAKE : fatal error U1077: 'W:\OS2\CMD.EXE' : return code '1'
Stop.
with this makefile,
Code: [Select]
walker : walker.exe

walker.exe : walker.obj walker.res walker.def
   gcc -Zomf walker.obj walker.def
   rc walker.res

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

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

Need to read the documentation, probably a define missing.
Hmm, the def file is broken, need to remove the underline prefix so it reads EXPORTS ClientWndProc rather then EXPORTS _ClientWndProc
Edit:, read the readme.txt, it was actually written for a different GCC port, GCC/2, not EMX.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 03:24:01 am
Better makefile,
Code: [Select]
walker : walker.exe

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

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

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

along with the def change compiles and runs fine here, if it isn't finding os2.h in your setup, something is broken.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 03:50:21 am
Here's the updated package if you want to upload to Hobbes. Added a clean target to the makefile, nmake clean.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 04:51:47 am
Thanks Lars, Dave.

Dave, I'm using your sample now.

I did a:
SET C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45
run nmake , and I still get some errors:

Quote

Operating System/2 Program Maintenance Utility

Version 4.00.001 Oct  4 2001

Copyright (C) IBM Corporation 1988-2001

Copyright (C) Microsoft Corp. 1988-1991

All rights reserved.

   gcc -Zomf -c -O2 walker.c -o walker.obj
In file included from c:/usr/include/os2tk45/os2.h:33,
                 from walker.c:29:
c:/usr/include/os2tk45/os2def.h:99:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PUCHAR16'
   99 | typedef UCHAR     * _Seg16 PUCHAR16;
      |                            ^~~~~~~~
c:/usr/include/os2tk45/os2def.h:100:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PCHAR16'
  100 | typedef CHAR      * _Seg16 PCHAR16;
      |                            ^~~~~~~
c:/usr/include/os2tk45/os2def.h:138:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PVOID16'
  138 | typedef VOID   * _Seg16  PVOID16;
      |                          ^~~~~~~
c:/usr/include/os2tk45/os2def.h:144:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PBOOL16'
  144 | typedef BOOL16     * _Seg16 PBOOL16;
      |                             ^~~~~~~
In file included from walker.c:30:
C:/usr/lib/gcc/i686-pc-os2-emx/9/include-fixed/stddef.h:56:10: fatal error: sys/_types.h: No such file or directory
   56 | #include <sys/_types.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
NMAKE : fatal error U1077: 'C:\OS2\CMD.EXE' : return code '1'
Stop.


What else do you think I'm missing? Do I have to make a change on OS2.h?

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 05:10:33 am
You're picking up too much from the toolkit, which conflicts with GCC/kLIBC. You want to end up using os2emx.h (which /usr/include/os2.h calls), not the toolkit os2.h.
Do you have a c:\usr\include\os2.h? Does it still fail with C_INCLUDE_PATH cleared, ie set C_INCLUDE_PATH=
You could check out what the preprocessor thinks by adding -E to the walker.obj gcc line and looking at walker.obj
Title: Re: Compiling a PM sample with GCC
Post by: Lars on March 30, 2022, 09:48:34 am
As Dave suggested, DO NOT use the IBM provided toolkit when it comes to using gcc.exe. Apparently, gcc.exe does not understand some of the specific keywords (like "_Seg16") that the WATCOM and IBM compilers understand.

You should have a \usr\include\os2.h file and, without any further customization, that file will include <os2emx.h> which is basically the "merge" of all individual header files from the IBM toolkit (at least the BSE and PM and WIN related header files). That is by far the easiest way to go for gcc.exe.

I think the IBM provided toolkit files were packaged for those developers that intend to use WATCOM or the IBM provided toolchain (Visual Age C++). Maybe that should have been stated right away ...
Title: Re: Compiling a PM sample with GCC
Post by: Lars on March 30, 2022, 09:53:52 am
Actually, GCC wants the os2.h in @unixroot\usr\include and should find it on its own without C_INCLUDE_PATH or -I, if you want to use the one in the toolkit, you need to define USE_OS2_TOOLKIT_HEADERS 1 or edit os2.h around line 39. Should use the define though.
Likewise, if you need  Toolkit header like dive.h, the toolkit headers need to be at the end of the C include search path, C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45 or use -Idirafter=c:/usr/include/os2tk45.
Anyways, PMwalker seems to be designed for EMX, after editing the makefile to compile with kLIBC, I get,
Code: [Select]
        gcc -Zomf walker.obj walker.def
weakld: error: Unresolved symbol (UNDEF) '_ClientWndProc'.
weakld: info: The symbol is referenced by:
    H:/tmp/PMwalker/walker.def
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldZXONto.: line(20): protmode option not valid for an OS/2
EMX executable
Error! E2028: _ClientWndProc is an undefined reference
Error! E2044: exported symbol _ClientWndProc not found
NMAKE : fatal error U1077: 'W:\OS2\CMD.EXE' : return code '1'
Stop.
with this makefile,
Code: [Select]
walker : walker.exe

walker.exe : walker.obj walker.res walker.def
   gcc -Zomf walker.obj walker.def
   rc walker.res

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

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

Need to read the documentation, probably a define missing.
Hmm, the def file is broken, need to remove the underline prefix so it reads EXPORTS ClientWndProc rather then EXPORTS _ClientWndProc
Edit:, read the readme.txt, it was actually written for a different GCC port, GCC/2, not EMX.

Apparently, decades ago, GCC/2 either did not understand the "_System" keyword as a calling convention or the emx header files did not specify the "_System" keyword in which case the compiler defaults to the "C" calling convention that in turn will lead to an underscore being prepended to the symbol name (thank god, the "C" and the "_System" calling conventions have about the same rules regarding argument passing and stack cleanup ...).
If I now look into \usr\include\os2.h and \usr\include\os2emx.h, everything is fine and gcc.exe will properly resolve the EXPENTRY macro definition to the "_System" keyword.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 02:56:26 pm
Hi

I have installed the RPM os2tk45 and it is located on the c:\usr, and also the IBM toolkit installed on D:\OS2TK45.
I had removed all references to the D:\OS2TK45 on the config.sys. I'm using nmake Version 4.00.001.

I'm attaching the OS2.h I have on C:\usr\include\os2tk45

I open a new  4CMD session:
run:
- SET C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45
- D:\OS2TK45\bin\nmake 2>&1 |tee make.out

And I get the same error:
Code: [Select]

Operating System/2 Program Maintenance Utility
Version 4.00.001 Oct  4 2001
Copyright (C) IBM Corporation 1988-2001
Copyright (C) Microsoft Corp. 1988-1991
All rights reserved.

gcc -Zomf -c -O2 walker.c -o walker.obj
In file included from c:/usr/include/os2tk45/os2.h:33,
                 from walker.c:29:
c:/usr/include/os2tk45/os2def.h:99:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PUCHAR16'
   99 | typedef UCHAR     * _Seg16 PUCHAR16;
      |                            ^~~~~~~~
c:/usr/include/os2tk45/os2def.h:100:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PCHAR16'
  100 | typedef CHAR      * _Seg16 PCHAR16;
      |                            ^~~~~~~
c:/usr/include/os2tk45/os2def.h:138:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PVOID16'
  138 | typedef VOID   * _Seg16  PVOID16;
      |                          ^~~~~~~
c:/usr/include/os2tk45/os2def.h:144:29: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PBOOL16'
  144 | typedef BOOL16     * _Seg16 PBOOL16;
      |                             ^~~~~~~
In file included from walker.c:30:
C:/usr/lib/gcc/i686-pc-os2-emx/9/include-fixed/stddef.h:56:10: fatal error: sys/_types.h: No such file or directory
   56 | #include <sys/_types.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.
NMAKE : fatal error U1077: 'C:\SYS\APPS\4OS2\4OS2.EXE' : return code '1'
Stop.


Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 03:26:00 pm
Hi

Just in case I created a new VM from my ArcaOS 5.0.7 vanilla, installed "yum install gcc os2tk45", copied nmake 4.

I opened a new  4CMD session:
run:
- SET C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45
- D:\OS2TK45\bin\nmake 2>&1 |tee make.out

Same error.  Can it be some issue with os2def.h ?

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 04:36:12 pm
Have you installed libc-dev? You shouldn't need the toolkit usually with GCC as it has its own version of the toolkit as Lars said.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 04:47:34 pm
I think the IBM provided toolkit files were packaged for those developers that intend to use WATCOM or the IBM provided toolchain (Visual Age C++). Maybe that should have been stated right away ...

GCC multimedia apps at least also need to use the toolkit as the EMX (now libc) version is missing them, this includes dive.h and IIRC mmpm2.lib. Trick is including the toolkit at the end of the include search, often with -idirafter.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 08:14:26 pm
Hi

Thanks, I didn't know that libc-devel had the include files.

So.
- yum install libc-devel
- yum remove os2tk45
and now opened a new  4CMD session:
run:
- SET C_INCLUDE_PATH=/@unixroot/usr/include;c:/usr/include/os2tk45
- nmake 2>&1 |tee make.out

Now I got a new error.
Code: [Select]
Operating System/2 Program Maintenance Utility
Version 4.00.001 Oct  4 2001
Copyright (C) IBM Corporation 1988-2001
Copyright (C) Microsoft Corp. 1988-1991
All rights reserved.

gcc -Zomf -c -O2 walker.c -o walker.obj
gcc.exe: fatal error: cannot execute 'as': spawnvp: No such file or directory
compilation terminated.
NMAKE : fatal error U1077: 'C:\SYS\APPS\4OS2\4OS2.EXE' : return code '1'
Stop.

Using:
- gcc.exe (GCC) 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
- nmake  Version 4.00.001
- rc - 4.00.011
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 08:54:52 pm
That's weird, as is the GNU compiler, part of GCC. Is as.exe in \usr\bin? Is your PATH correct in having c:\usr\bin near the beginning? Have you tried with cmd.exe instead of 4os2? I only use cmd.exe due to 4os2 acting different in some circumstances and breaking things.
Using the stock 4os2 install, it works fine here,
Code: [Select]
Operating System/2 Program Maintenance Utility
Version 3.00.013 Nov 17 1995
Copyright (C) IBM Corporation 1988-1995
Copyright (C) Microsoft Corp. 1988-1991
All rights reserved.

gcc -Zomf -c -O2 walker.c -o walker.obj
rc -r walker.rc
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.


Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef W:\OS2\RCPP.ERR -I G:\IBMCPP\INCLUDE -I G:\IBMCPP\INCLUDE\OS2 -I G:\IBMCPP\INC -I G:\IBMCPP\INCLUDE\SOM -I W:\usr\include\os2tk45\inc -I W:\usr\include\os2tk45\gl -I W:\usr\include\os2tk45

walker.rc
gcc -Zomf walker.obj walker.def -o walker.exe
Warning! W1058: file ld3xIFSd.: line(20): protmode option not valid for an OS/2 EMX executable
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


Writing resources to OS/2 v2.0 Linear .EXE file
Writing 1 DEMAND resource object(s)
  Writing:  5552 bytes in 2 page(s)
    1.1 (1388 bytes)
    2.1 (1388 bytes)
    3.1 (1388 bytes)
    4.1 (1388 bytes)
Writing Extended Attributes:  Default Icon
Writing Extended Attributes:  Checksum

Guess the protmode line could be removed from the def file. The IBM linkers don't complain about it and others have acted surprised about the warning.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 09:26:00 pm
Hi. I don't have as.exe, on which rpm package it is located?
"yum whatprovides" is not working for me right now, the server is giving me some errors.

cmd.exe gave me the same error.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 09:33:51 pm
Hi

It worked in my other environment. It build the exe and I can see the animation on the icon box.

I just want to know which package contains "as.exe" just to try it out on the other VM, and document it. 

Quote

Operating System/2 Program Maintenance Utility

Version 4.00.001 Oct  4 2001

Copyright (C) IBM Corporation 1988-2001

Copyright (C) Microsoft Corp. 1988-1991

All rights reserved.

   gcc -Zomf -c -O2 walker.c -o walker.obj
   rc -r walker.rc
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.


Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef C:\OS2\RCPP.ERR -I C:\usr\include\os2tk45 -I C:\usr\include\os2tk45\inc -I C:\usr\include\os2tk45\gl -I C:\usr\include\os2tk45

walker.rc
   gcc -Zomf walker.obj walker.def -o walker.exe
Warning! W1058: file ldH89pwk.: line(20): protmode option not valid for an OS/2 EMX executable
   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


Writing resources to OS/2 v2.0 Linear .EXE file
Writing 1 DEMAND resource object(s)
  Writing:  5552 bytes in 2 page(s)
    1.1 (1388 bytes)
    2.1 (1388 bytes)
    3.1 (1388 bytes)
    4.1 (1388 bytes)
Writing Extended Attributes:  Default Icon
Writing Extended Attributes:  Checksum

Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 09:55:34 pm
Binutils I guess if GCC didn't include it. Installing GCC should really pull in the binutils and libc-devel
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 30, 2022, 10:18:49 pm
Hi
I had updated the readme files and comments on the files, and put a very liberal license since it is sample source code. I will upload this version to hobbes if there is no more comments .

Regards.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 10:55:59 pm
Drop the C_INCLUDE_PATH stuff, it is not needed and will confuse people. While after dropping the C_INCLUDE_PATH line in the compile.cmd, it is not really needed as it should just compile. Perhaps mention the 2&1 tee make.log in the readme under trouble shooting tips or such.
Perhaps change the first line in the makefile to read something like # nmake makefile for those who don't read the readme and start out using gmake.
Might as well remove the protmode line in the def file too.
Thanks
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on March 30, 2022, 11:17:42 pm
BTW, it is good practice when using C_INCLUDE_PATH to end it with ;%C_INCLUDE_PATH% in case it has already been set somewhere like if you set up the environment for a different GCC such as Paul's releases.
Same with CPLUS_INCLUDE_PATH and LIBRARY_PATH
As an example, I compiled PMwalker with GCC 9.4.0, part of my environment, (@unixroot=W:)
Code: [Select]
[H:\tmp\PMwalker]set C_INCLUDE_PATH
C_INCLUDE_PATH=W:/USR/local940/lib/gcc/i386-pc-os2-emx/9.4.0/include;W:/USR/local940/include;W:/USR/include;%C_INCLUDE_PATH%;

[H:\tmp\PMwalker]set CPLUS_INCLUDE_PATH
CPLUS_INCLUDE_PATH=W:/USR/local940/include/c++/9.4.0;W:/USR/local940/include/c++/9.4.0/i386-pc-os2-emx;W:/USR/local940/include/c++/9.4.0/backward;W:/USR/local940/include;W:/USR/include;%CPLUS_INCLUDE_PATH%;

[H:\tmp\PMwalker]set LIBRARY_PATH
LIBRARY_PATH=W:/USR/local940/lib/gcc/i386-pc-os2-emx/9.4.0;W:/USR/local940/lib;W:/USR/lib;%LIBRARY_PATH%;

[H:\tmp\PMwalker]gcc --version
gcc (GCC) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on March 31, 2022, 06:01:13 pm
Thanks Dave, Lars

I learned that gcc does not work with the OS/2 toolkit header files, and that the "os2tk45" package is not the right one, it is "libc-devel" for those files.

I'm uploading here the changes to the sample with the comments suggested by Dave. Later I will upload it to hobbes if there is no any additional change.

Maybe in the future I will try the same sample with gmake and some other PM samples with gcc.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Lars on March 31, 2022, 11:32:50 pm
Hi Martin,

just as a side note: for a 32-bit application, the HEAPSIZE keyword in the DEF file is completely superfluous (it has no effect for 32-bit applications). But it won't hurt either, it will just be ignored by any 32-bit linker. It is a remnant of 16-bit linkers (and the original source code dates back to 16-bit times).

The STACKSIZE keyword however is relevant. 8 kBytes is very small stack for a PM application. It's obviously ok for this application but it should definitely be bigger for a "normal sized" PM application. Maybe 64 kByte would be a better choice.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 01, 2022, 03:06:05 am
Hi Martin, looks good. Unless you'd rather have a Gnu makefile, upload it.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 01, 2022, 04:12:54 am
Hi Martin,

just as a side note: for a 32-bit application, the HEAPSIZE keyword in the DEF file is completely superfluous (it has no effect for 32-bit applications). But it won't hurt either, it will just be ignored by any 32-bit linker. It is a remnant of 16-bit linkers (and the original source code dates back to 16-bit times).

The STACKSIZE keyword however is relevant. 8 kBytes is very small stack for a PM application. It's obviously ok for this application but it should definitely be bigger for a "normal sized" PM application. Maybe 64 kByte would be a better choice.

Hi Lars

Do you mean to put the DEF file like this?
Quote
; WALKER defintion file

NAME            WALKER  WINDOWAPI

DESCRIPTION     'Walker utility, 2022'
STACKSIZE       64512
EXPORTS         ClientWndProc

It keeps compiling and working here.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 01, 2022, 06:29:15 am
Hi Martin, the stack should probably be an even hex number, in this case 64k equals 65536 or 0x10000H.
There's other ways to set the stack size such as the -Zstack option, -Zstack 0x2000 gives 8MB stack. I usually just go with the default, which is pretty big now a days, though I can't remember how big. In the EMX days it was on the small side.
Generally executables don't need a def file, though they are handy for adding bldlevel info and in the case of a PM app like this, the WINDOWAPI forces it to be a PM app rather then cmd line. It is possible to morph into a PM app as well, you end up with a console window along the PM window.
I think a lot of this def file is from the 16 bit days and can be simplified to,
Code: [Select]
; WALKER defintion file

NAME            WALKER WIDOWAPI

DESCRIPTION     'Walker utility (C) Lee S. Fields, 1989'

or better, something like,
Code: [Select]
; WALKER defintion file

NAME            WALKER WINDOWAPI

DESCRIPTION     '@#OS2World:4.00#@##1## 31 Mar 2022 21:17:32     ARCAOS-444::::::v4.0@@Moving icon test program'

Which gives,

Code: [Select]
H:\tmp\PMwalker>bldlevel walker.exe
Build Level Display Facility Version 6.12.675 Sep 25 2001
(C) Copyright IBM Corporation 1993-2001
Signature:       @#OS2World:4.00#@##1## 31 Mar 2022 21:17:32     ARCAOS-444::::::v4.0@@Moving icon test program
Vendor:          OS2World
Revision:        4.00
Date/Time:       31 Mar 2022 21:17:32
Build Machine:   ARCAOS-444
FixPak Version:  v4.0
File Version:    4.0
Description:     Moving icon test program
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 01, 2022, 02:30:56 pm
Thanks, I was wondering where to add the bldlevel stuff.

I had updated the release. With the changes on the DEF file, it keeps compiling.
What happens if I had removed the "STACKSIZE" and keep compiling it as "gcc -Zomf" without the "-Zstack ", what stacksize does it assign?

More questions. Will it be recommended to use GNU make instead of nmake? Maybe trying to focus on compiling with more open source tools. Will it be better to use cmake?

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 01, 2022, 04:28:05 pm
From the GCC 3.3.5 changelog,
Code: [Select]
2005-08-21: knut st. osmundsen <bird-gccos2-spam@anduin.net>
    - emxbind, emxomfld:
        o Default stack size set to 1MB.
          The old defaults were 8MB (emxbind) and 8KB (emxomfld).
Not sure if Bitwise changed it since.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 01, 2022, 04:50:43 pm
More questions. Will it be recommended to use GNU make instead of nmake? Maybe trying to focus on compiling with more open source tools. Will it be better to use cmake?

Regards

Cmake is probably overkill, plus I don't know it much.
Converting the makefile to GNU make.
Make uses tabs for separators so change the spaces to a tab and it almost works, with a simple make command ending with,
...
Code: [Select]
Writing Extended Attributes:
Default Icon
Writing Extended Attributes:  Checksum
gcc     walker.c walker.exe   -o walker
ld.exe: malformed input file (not rel or archive) walker.exe
make: *** [walker] Error 1

make walker.exe works. Seems GNU make helpfully creates a minimal compile rule for walker.
Changing the line "walker : walker.exe" to "all : walker.exe" fixes that.
make clean fails as GNU make is using sh.exe as a shell. Can change the shell (set MAKESHELL=cmd.exe) or use rm -rf which seems better, so we get this (comments need updating)
Code: [Select]
# nmake makefile
#
# Tools used:
#  Compile::Resource Compiler
#  Compile::GNU C
#  Make: nmake
all : walker.exe

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

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

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

clean :
        rm -rf *exe *RES *obj

Now the makefile works with GNU make and still works with nmake. Remember those are tabs rather then a bunch of spaces.

Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 01, 2022, 05:54:09 pm
Thanks Dave.
It worked for me with GNU Make 3.81 k2 (2017-11-10), that's the last one for OS/2, right?

I'm attaching the changes.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 01, 2022, 06:04:38 pm
Hi

Just chatting with Tellie, he let me know that "kbuild-make" is the package that has the make.exe file. I also installed that one and worked.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 02, 2022, 02:09:43 am
Hi Martin, looking good. The comments at the beginning of the makefile could be updated and in walker.txt, refer to kbuild-make. When you upload, perhaps update the date in the description line in the def.
Thanks
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 10, 2022, 04:49:38 pm
Hi

I had also tried the BitCat sample. It compiled fine, but it gave me a lot warnings, but in my limited skill I read the warnings, read the EDM/2 wiki and updated some USHORT to ULONG, NULL to Zeros, changed BITMAPINFOHEADER to BITMAPINFOHEADER2 and BITMAPINFO to BITMAPINFO2 ...and now compiles with no warning.

It compiles with nmake. My issue is that with "make" it also compiles but gives me this warning:
Quote
ld.exe: malformed input file (not rel or archive) bitcat2.exe
make: *** [bitcat2] Error 1

Check attached file.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 10, 2022, 05:24:01 pm
Hi Martin, good job fixing the warnings, though if we turn on all warnings by adding -Wall to the bitcat2.obj rule, there are these,
Code: [Select]
gcc -Wall -Zomf -c -O2 bitcat2.c -o bitcat2.obj
bitcat2.c: In function 'main':
bitcat2.c:36:29: warning: pointer targets in passing argument 2 of 'WinRegisterClass' differ in signedness [-Wpointer-sign]
   36 |       WinRegisterClass(hab, szClientClass, ClientWndProc, CS_SIZEREDRAW, 0);
      |                             ^~~~~~~~~~~~~
      |                             |
      |                             CHAR * {aka char *}
In file included from W:/usr/include/os2.h:39,
                 from bitcat2.c:4:
W:/usr/include/os2emx.h:6138:47: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'CHAR *' {aka 'char *'}
 6138 | BOOL APIENTRY WinRegisterClass (HAB hab, PCSZ pszClassName, PFNWP pfnWndProc,
      |                                          ~~~~~^~~~~~~~~~~~
bitcat2.c:39:53: warning: pointer targets in passing argument 4 of 'WinCreateStdWindow' differ in signedness [-Wpointer-sign]
   39 |                                      &flFrameFlags, szClientClass, NULL,
      |                                                     ^~~~~~~~~~~~~
      |                                                     |
      |                                                     CHAR * {aka char *}
In file included from W:/usr/include/os2.h:39,
                 from bitcat2.c:4:
W:/usr/include/os2emx.h:6003:33: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'CHAR *' {aka 'char *'}
 6003 |     PULONG pflCreateFlags, PCSZ pszClientClass, PCSZ pszTitle,
      |                            ~~~~~^~~~~~~~~~~~~~
bitcat2.c: In function 'ClientWndProc':
bitcat2.c:70:57: warning: pointer targets in passing argument 3 of 'DevOpenDC' differ in signedness [-Wpointer-sign]
   70 |                   hdcMemory = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, 0);
      |                                                         ^~~
      |                                                         |
      |                                                         char *
In file included from W:/usr/include/os2.h:39,
                 from bitcat2.c:4:
W:/usr/include/os2emx.h:9979:51: note: expected 'PCSZ' {aka 'const unsigned char *'} but argument is of type 'char *'
 9979 | HDC APIENTRY DevOpenDC (HAB hab, LONG lType, PCSZ pszToken, LONG lCount,
      |                                              ~~~~~^~~~~~~~
gcc -Zomf bitcat2.obj bitcat2.def -o bitcat2.exe

As for the error you see, GNU make is helpfully trying to do the first rule, "bitcat2 : bitcat2.exe" and compile bitcat2. Fix is to change bitcat2 to all so the first rule is "all : bitcat2.exe"
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 10, 2022, 06:37:38 pm
Thanks Dave for the tip.

1) I changed to:
 all : bitcat2.exe
Now make does not gives me the warning. 

2) I replaced
 static CHAR  szClientClass[] = "BitCat2";
for
 unsigned char     szClientClass[] = "BitCat2";
and two warnings down.

3) I have no idea what to do with the warning on line 70.  The sample on the INF file says "*" is fine, but I guess it asks me to declare it as "unsigned char" ?


Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 11, 2022, 12:33:00 am
Hi again,
3) I have no idea what to do with the warning on line 70.  The sample on the INF file says "*" is fine, but I guess it asks me to declare it as "unsigned char" ?

The Presentation Manager Programing Guide and Ref has this for syntax,
Code: [Select]
This function creates a device context.


#define INCL_DEV /* Or use INCL_PM, Also in COMMON section */
#include <os2.h>

HAB             hab;       /*  Anchor-block handle. */
LONG            lType;     /*  Type of device context: */
PSZ             pszToken;  /*  Device-information token. */
LONG            lCount;    /*  Number of items. */
PDEVOPENDATA    pdopData;  /*  Open-device-context data area. */
HDC             hdcComp;   /*  Compatible-device-context handle. */
HDC             hdc;       /*  Device-context handle: */

hdc = DevOpenDC(hab, lType, pszToken, lCount,
        pdopData, hdcComp);


So I cast the "*" to PSZ and combined with your fix, no more warnings. Whether in this case if that's the best fix, I think so but perhaps someone with better understanding can chime in as I'm not sure of the size of PSZ
Code: [Select]
H:\tmp\BitCat>diff -u BITCAT2.C.orig BITCAT2.C
--- BITCAT2.C.orig      2022-04-10 09:34:22.000000000 -0700
+++ BITCAT2.C   2022-04-10 15:13:00.000000000 -0700
@@ -16,7 +16,7 @@

 int main(void)
    {
-      static CHAR       szClientClass[] = "BitCat2";
+      unsigned char     szClientClass[] = "BitCat2";
       static ULONG      flFrameFlags = FCF_TITLEBAR      | FCF_SYSMENU  |
                                        FCF_SIZEBORDER    | FCF_MINMAX   |
                                        FCF_SHELLPOSITION | FCF_TASKLIST;
@@ -67,7 +67,7 @@
       switch(msg)
          {
             case WM_CREATE:
-                  hdcMemory = DevOpenDC(hab, OD_MEMORY, "*", 0L, NULL, 0);
+                  hdcMemory = DevOpenDC(hab, OD_MEMORY, (PSZ)"*", 0L, NULL, 0);


                   sizl.cx = 0;
                   sizl.cy = 0;
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 11, 2022, 12:40:34 am
Thinking about it, perhaps you should have changed the static CHAR to static unsigned char. The static keyword controls where the memory for the variable is allocated, IIRC, static is heap instead of stack.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 11, 2022, 02:18:31 am
Thanks Dave.

I followed your advice and I no longer had any warnings. I guess that's is with this sample. I will work on the readme file and upload it later to hobbes.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 11, 2022, 04:05:22 am
Good. Further reading of the documentation says the cast and the warning were harmless as "*" means no information taken from the initialization file. So looks good and always nice not to have warnings.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 11, 2022, 10:28:40 pm
Thanks Dave

I updated but Gits.
- https://github.com/OS2World/DEV-SAMPLES-PM-PMWalker2 (https://github.com/OS2World/DEV-SAMPLES-PM-PMWalker2)
- https://github.com/OS2World/DEV-SAMPLES-PM-BitCat (https://github.com/OS2World/DEV-SAMPLES-PM-BitCat)

I will keep trying some other PM samples with gcc and post back.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 12, 2022, 03:11:02 am
Hi

I tried this sample "Boxes 3", I had fixed the some warning and it compiles. It says it is a "OS/2 PM program that draws nested boxes in client window", but when I run it, it runs on the background and I can not see anything.

I got this warning that I don't know what it refers to:
Quote
boxes3.rc
gcc -Zomf boxes3.obj boxes3.def -o boxes3.exe
Warning! W1058: file ld1lfMJw.: line(20): protmode option not valid for an OS/2 EMX executable
rc boxes3.res

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 12, 2022, 06:36:58 am
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.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on April 12, 2022, 07:18:32 am
Meanwhile I was playing with adding a bldlevel string to Bitcat. Need https://88watts.net/download/addtofile-1.03.zip (https://88watts.net/download/addtofile-1.03.zip) on the path or in the program directory.
Here's a first try at updating the makefile to output this,
Code: [Select]
[H:\tmp\BitCat]bldlevel bitcat2.exe
Build Level Display Facility Version 6.12.675 Sep 25 2001
(C) Copyright IBM Corporation 1993-2001
Signature:       @#OS2World:0.4.0#@##1## 11 Apr 2022 20:53:25     ARCAOS-444::::0::V0.4.0@@Bitmap Demo Program
Vendor:          OS2World
Revision:        0.04.0
Date/Time:       11 Apr 2022 20:53:25
Build Machine:   ARCAOS-444
FixPak Version:  V0.4.0
File Version:    0.4
Description:     Bitmap Demo Program

The Gnu Makefile,
Code: [Select]
# gmake makefile
#
# Tools used:
#  Compile::Resource Compiler
#  Compile::GNU C
#  Make: GNU make
#  https://88watts.net/download/addtofile-1.03.zip for AddToFile.cmd

all : bitcat2.exe

bitcat2.exe : bitcat2.obj bitcat2.def
gcc -Zomf bitcat2.obj bitcat2.def -o bitcat2.exe

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

bitcat2.def : AddToFile.tmp
@echo Building DEF file
$(shell echo NAME            BitCat2 WINDOWAPI > bitcat2.def)
$(shell cat AddToFile.tmp >> bitcat2.def)

AddToFile.tmp :
@echo Building description for bldlevel
$(shell AddToFile.cmd AddToFile.tmp,description,BLDLEVEL,OS2World,0.4.0,Bitmap Demo Program,V0.4.0)

clean :
rm -rf *.exe *.RES *.obj *.def *.tmp

Do a make clean and then make. Some of this stuff should be in variables, tomorrow maybe.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on April 12, 2022, 03:07:39 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
Title: Re: Compiling a PM sample with GCC
Post by: Silvan Scherrer on April 12, 2022, 04:10:00 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)
3) use wlink instead of ilink. there is a wlink and wrc rpm.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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




Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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.
Title: Re: Compiling a PM sample with GCC
Post by: Silvan Scherrer 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.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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

Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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?
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo 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 */
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide 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 (https://github.com/OS2World/DEV-SAMPLES-PM-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
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on June 29, 2022, 02:26:39 am
Hi Martin, the warning is from ilink it seems, which doesn't seem to handle WINDOWCOMPAT or doesn't like how it is being called. From the Tools Reference from the toolkit,
Code: [Select]
If <apptype> is given, it defines the type of application:

WINDOWAPI
Presentation Manager* application. The application uses the API provided by the Presentation Manager and must be executed in the Presentation Manager environment.

WINDOWCOMPAT
Application compatible with Presentation Manager. The application can run inside the Presentation Manager, or it can run in a separate screen group. An application can be of this type if it uses the proper subset of OS/2 video, keyboard, and mouse functions supported in the Presentation Manager applications.

NOTWINDOWCOMPAT
Application that is not compatible with the Presentation Manager and must operate in a separate screen group from the Presentation Manager.

OK, looking at the error LNK4072, it means
Code: [Select]
L4072 changing application type from oldname to newname
Explanation:  The application type specified with /PMTYPE is different from that in .DEF file. LINK386 is using the application type indicated.
Action:  Edit the file and relink.

So somewhere there are conflicts between WINDOWAPI and WINDOWCOMPAT, possibly it is emxomfld causing it but search your source for both.
Title: Re: Compiling a PM sample with GCC
Post by: Lars on June 29, 2022, 02:13:18 pm
The problem is a bit convoluted as it is intransparent how the gcc shell eventually calls the system linker (be it LINK386, ILINK or WLINK) when you do this:

gcc -Zomf pmhello.obj pmhello3.obj pmhello.def -o pmhello3.exe

In any case, it appears that the gcc shell always calls the system linker with NO apptype argument at all which in turn defaults to WINDOWCOMPAT. The def file in turn properly tells the linker that the app type is WINDOWAPI. It is the system linker that then issues the warning about apptype mismatch.

It's nothing to worry about and in fact you can direct ILINK to ignore that warning and not issue it.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on June 29, 2022, 05:36:41 pm
Well, we can add -v to the gcc linker line,
Code: [Select]
gcc -Zomf -v  pmhello.obj pmhello1.obj pmhello.def -o pmhello1.exe
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=W:/usr/bin/../libexec/gcc/i686-pc-os2-emx/9/lto-wrapper.exe
Target: i686-pc-os2-emx
Configured with: D:/Users/dmik/rpmbuild/BUILD/gcc-os2-gcc-9_2_0-release-os2-b3/configure --disable-bootstrap --enable-languages=c,c++ --build=i686-pc-os2-emx --with-sysroot=/@unixroot --prefix=/@unixroot/usr --mandir=/@unixroot/usr/share/man --infodir=/@unixroot/usr/share/info --with-bugurl=https://github.com/bitwiseworks/gcc-os2/issues --enable-shared --enable-threads --enable-checking=release --disable-multilib --with-system-zlib --with-gcc-major-version-only --without-isl --with-tune=generic --with-arch=i686 --with-gnu-as --disable-libstdcxx-pch
Thread model: os2
gcc version 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00) (GCC)
COMPILER_PATH=W:/usr/bin/../libexec/gcc/i686-pc-os2-emx/9/;W:/usr/bin/../libexec/gcc/
LIBRARY_PATH=W:/usr/bin/../lib/gcc/i686-pc-os2-emx/9/;W:/usr/bin/../lib/gcc/;W:/usr/bin/../lib/gcc/i686-pc-os2-emx/9/../../../;/@unixroot/usr/lib/
COLLECT_GCC_OPTIONS='-Zomf' '-v' '-o' 'pmhello1.exe' '-mtune=generic' '-march=i686'
 emxomfld.exe -o pmhello1.exe W:/usr/bin/../lib/gcc/i686-pc-os2-emx/9/../../../crt0.obj -LW:/usr/bin/../lib/gcc/i686-pc-os2-emx/9 -LW:/usr/bin/../lib/gcc -LW:/usr/bin/../lib/gcc/i686-pc-os2-emx/9/../../.. -L/@unixroot/usr/lib pmhello.obj pmhello1.obj pmhello.def -lgcc_so_d -lc_alias -lc_dll -los2 -lend
COLLECT_GCC_OPTIONS='-Zomf' '-v' '-o' 'pmhello1.exe' '-mtune=generic' '-march=i686'

And could use the above emxomfld command line with the drive letter fixed for your system
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on June 30, 2022, 04:21:35 am
Hi

I don't know what happened now. My ArcaOS 5.0.7 dev VM got screwed again with the RC compiler asking me for OS2.h, while it was not giving me problem before.

I went back to try to compiler PMWalker and I get this error with RC.

Code: [Select]
rc -r walker.rc
fatal error C1015: cannot open include file 'os2.h'
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.


Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef C:\OS2\RCPP.ERR
make: *** [walker.res] Error 3

This is the second time I get this problem and I don't know how I solved it first time. The Dev enviroment is very basic with all installed from rpm/yum and added the ilinker 5 manually. I'm attaching the testlog just in case someone has a suggestion.

Dave, I don't understand how I should use "emxomfld".

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on June 30, 2022, 05:22:32 am
Running rc /? we see how it finds includes, simplest is the INCLUDE environment variable. Something like SET INCLUDE=%UNIXROOT%\usr\include; or SET INCLUDE=%UNIXROOT%\usr\include\os2tk45; First one works fine, 2nd might be more proper.

Here's an example of using emxomfld with PMHello,
Code: [Select]
# make makefile
#
# Tools used:
#  Compile::Resource Compiler
#  Compile::GNU C
#  Make: make
all : pmhello1.exe pmhello2.exe pmhello3.exe

pmhello1.exe : pmhello.obj pmhello1.obj pmhello.def
# gcc -Zomf -v  pmhello.obj pmhello1.obj pmhello.def -o pmhello1.exe
emxomfld.exe -o pmhello1.exe /@unixroot/usr/bin/../lib/gcc/i686-pc-os2-emx/9/../../../crt0.obj -L/@unixroot/usr/bin/../lib/gcc/i686-pc-os2-emx/9 -L/@unixroot/usr/bin/../lib/gcc -L/@unixroot/usr/bin/../lib/gcc/i686-pc-os2-emx/9/../../.. -L/@unixroot/usr/lib pmhello.obj pmhello1.obj pmhello.def -lgcc_so_d -lc_alias -lc_dll -los2 -lend

pmhello2.exe : pmhello.obj pmhello2.obj pmhello.def
gcc -Zomf pmhello.obj pmhello2.obj pmhello.def -o pmhello2.exe

pmhello3.exe : pmhello.obj pmhello3.obj pmhello.def
gcc -Zomf pmhello.obj pmhello3.obj pmhello.def -o pmhello3.exe

pmhello.obj : pmhello.c
gcc -Wall -Zomf -c -O2 pmhello.c -o pmhello.obj

pmhello1.obj : pmhello1.c
gcc -Wall -Zomf -c -O2 pmhello1.c -o pmhello1.obj

pmhello2.obj : pmhello2.c
gcc -Wall -Zomf -c -O2 pmhello2.c -o pmhello2.obj

pmhello3.obj : pmhello3.c
gcc -Wall -Zomf -c -O2 pmhello3.c -o pmhello3.obj

clean :
rm -rf *exe *RES *obj

It is mostly to show how GCC calls emxomfld. Not sure how to catch how emxomfld calls ilink.
EDIT: Catch how ilink is called by setting the linker to echo,
Code: [Select]
set EMXOMFLD_LINKER=echo
Don't forget to set it back after.
Title: Re: Compiling a PM sample with GCC
Post by: Lars on June 30, 2022, 11:51:20 am
1) regading rc: this is typically a problem with multiple versions of rc.exe existing on a standard OS/2 or AN system.
There is rc.exe in directory \OS2 and then there is a 16-bit version and also a 32-bit version in \OS2TK45\BIN or whereever the OS/2 toolkit was installed. What could be done is to rename \OS2\RC.EXE to something else which should then ensure that the toolkit version of RC.EXE is called.

2) I don't know what you are trying to accomplish regading the linker.
The problem is that nothing tells the linker what app type to produce, apart from what is specified via the DEF file.
The default app type is WINDOWCOMPAT.
You would need to introduce a "pass through" for an app type so that gcc.exe can pass it to emxomfld.exe so that it in turn can pass it to the native linker (LINK386, ILINK, WLINK, whatever is specified via  EMXOMFLD_LINKER).
But that's simply not worth the effort as the native linker will take what is in the DEF if it can find a DEF file.
Title: Re: Compiling a PM sample with GCC
Post by: Andreas Schnellbacher on June 30, 2022, 01:04:39 pm
About rc:

In my programming env I have the 32-bit version installed:
Code: [Select]
epm: {0}[G:\dev\netlabs\nepmd\trunk] rc /?
IBM RC (Resource Compiler) Version 5.00.007 Jan 30 2003

That's the one from the toolkit 4.5, also recommended for the Mozilla project long times ago. It needs an extended DPATH as well for to find its .msg file. Other 32-bit versions are extremely buggy.

I still have the 16-bit \OS2\RC.EXE in PATH, but that comes after the programming env. At any rate the toolkit versions of all files must be found first.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on June 30, 2022, 04:42:13 pm
Even rc 5.00.007 needs INCLUDE set to find os2.h. After clearing %INCLUDE%, I get a more informative error,
Code: [Select]
        rc -r walker.rc
IBM RC (Resource Compiler) Version 5.00.007 Jan 30 2003
Copyright (C) IBM Corp. 2003.
- Licensed Materials - Program Property of IBM - All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.


RC :(walker.rc:1:17):Error 2068:The file cannot be searched because of missing include options. [<os2.h>]
RC :(walker.rc:8:2):Error 1009:RC detected errors during compilation.
Compile ending.
NMAKE : fatal error U1077: 'W:\OS2\CMD.EXE' : return code '1'
Stop.

Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on June 30, 2022, 05:30:34 pm
About the PMHello sample.

2) I don't know what you are trying to accomplish regading the linker.
The problem is that nothing tells the linker what app type to produce, apart from what is specified via the DEF file.
The default app type is WINDOWCOMPAT.
You would need to introduce a "pass through" for an app type so that gcc.exe can pass it to emxomfld.exe so that it in turn can pass it to the native linker (LINK386, ILINK, WLINK, whatever is specified via  EMXOMFLD_LINKER).
But that's simply not worth the effort as the native linker will take what is in the DEF if it can find a DEF file.
This is a good question. The sample is compiling and running and I'm getting the "warning LNK4072: changing application type from WINDOWCOMPAT to WINDOWAPI " warning.

My objective is to don't have warnings on this sample if this can be fixed somewhere in the source code. If nothing can not be done and it is a limitation of the tools, I will stop this and move to other sample to compile.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Lars on June 30, 2022, 07:11:58 pm
It's a tools warning and not a warning of the running app.
You cannot fix that in the source code.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on July 01, 2022, 02:39:40 am
Simplest is to just use the recommended linker for GCC, namely wlink. Ilink 5 was only licensed to compile Mozilla, not sure if that changed for eCS and/or ArcaOS and we have the source and a maintainer for wlink.
Could also use ld, remove all the -Zomf and change the .obj to .o and it will compile without the warning.
In theory you could also pass an argument to ilink using something like -Zlinker /PMtype but I'm too lazy to figure out the exact argument.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on July 01, 2022, 04:04:23 am
Ok. I think I need to try using wlink, since I want to stick with open source as much as possible.

which RPM package has wlink? Is it wlink.exe or wl.exe ?
- "wacom-wlink-hll" ??
- "gcc-wlink" just have a dummy .txt file.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on July 01, 2022, 06:09:56 am
Ok. I think I need to try using wlink, since I want to stick with open source as much as possible.

which RPM package has wlink? Is it wlink.exe or wl.exe ?
- "wacom-wlink-hll" ??
- "gcc-wlink" just have a dummy .txt file.

Regards

Ideally you need both, watcom-wlink-hll gives you wl.exe and gcc-wlink edits config.sys. Current OpenWatcom's wlink.exe is now the same as wl.exe, though that is fairly recent IIRC and not in 1.9. Also beware of the OpenWatcom fork on Github, it was forked a while back and its aim is 64bit support and doesn't have any recent OS/2 fixes.
If you want to edit config.sys yourself or use a cmd file, run emxomfld with no arguments to get the Environment variables you need.
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on July 04, 2022, 03:39:47 am
Hi Dave

Ideally you need both, watcom-wlink-hll gives you wl.exe and gcc-wlink edits config.sys. Current OpenWatcom's wlink.exe is now the same as wl.exe, though that is fairly recent IIRC and not in 1.9. Also beware of the OpenWatcom fork on Github, it was forked a while back and its aim is 64bit support and doesn't have any recent OS/2 fixes.
If you want to edit config.sys yourself or use a cmd file, run emxomfld with no arguments to get the Environment variables you need.

I installed both packages (wacom-wlink-hll and gcc-wlink), just in case I don't have wlink.exe, just wl.exe. I guess this is fine.

The config.sys now has:
Quote
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK

Ilink is now gone of my system, I had rebooted and the bitcat and PMHELLO samples are compiling fine. I guess wl.exe is working fine for the moment here. I got no warning on PMHELLO. I think I'm done with that sample and I will upload it at hobbes too, but if there is any suggestion for the sample please let me know.

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on July 04, 2022, 04:00:10 am
Hi

Now I want to try to find the source of the issue on why rc.exe and wrc.exe tells me it can not find OS2.H.
I'm returning to the PMWalker sample, since it uses RC.exe.

1) First I search on the different drives to see if there is a duplicated rc.exe somewhere. I was not able to find it.

2) I added:
Code: [Select]
SET C_INCLUDE_PATH=/@unixroot/usr/include;%C_INCLUDE_PATH%
 SET INCLUDE=@unixroot/usr/include;%INCLUDE%
make 2>&1 |tee make.out
I get the same error as always:
Code: [Select]
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
rc -r walker.rc
fatal error C1015: cannot open include file 'os2.h'
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.


Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef C:\OS2\RCPP.ERR -I @unixroot/usr/include
make: *** [walker.res] Error 3


3) If I change the makefile to wrc.exe I also get:
Code: [Select]
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

4) OS2.H is located in my C drive:
Quote
[C:\]dir os2.h /s

The volume label in drive C is ARCAOS.
The Volume Serial Number is 6CE8:A5BF.

Directory of C:\usr\include

 8-26-21  9:13a           723    124 a---  os2.h
        1 file(s)         723 bytes used
Total files listed:
        1 file(s)           723 bytes used
                   41,062,080 K bytes free

Any other suggestions?

Regards
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on July 04, 2022, 06:23:41 am
SET INCLUDE=%UNIXROOT%/usr/include;%INCLUDE% works here. Remember that rc etc are Dosish programs and don't understand things like @unixroot. Ideally the directory separators should be \ but / seems OK.
Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on July 04, 2022, 06:32:43 am
As an alternative, could add the include to the makefile in the walker.res rule,
Code: [Select]
rc -r -i %%UNIXROOT%%\usr\include walker.rc
Seems that the % needs doubled up, escape character?
Title: Re: Compiling a PM sample with GCC
Post by: Martin Iturbide on July 04, 2022, 10:31:27 pm
As an alternative, could add the include to the makefile in the walker.res rule,
Code: [Select]
rc -r -i %%UNIXROOT%%\usr\include walker.rc
Seems that the % needs doubled up, escape character?

There was no luck with me with this change. I get this error:

Code: [Select]
[E:\PROJECTS\SAMPLEPACK\PMWALKER]make   2>&1  | tee make.out
gcc -Wall -Zomf -c -O2 walker.c -o walker.obj
rc -r -i %%UNIXROOT%%\usr\include walker.rc
fatal error C1015: cannot open include file 'os2.h'
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.


Creating binary resource file walker.RES
RC:  RCPP -E -D RC_INVOKED -W4 -f walker.rc -ef C:\OS2\RCPP.ERR -I %%UNIXROOT%%\usr\include
make: *** [walker.res] Error 3

Title: Re: Compiling a PM sample with GCC
Post by: Dave Yeo on July 05, 2022, 12:00:36 am
I did the change for nmake. Make might work using cmd.exe as the shell. SET MAKESHELL=cmd.exe or use /@unixroot/usr/include with sh.exe as the shell.
Title: Re: Compiling a PM sample with GCC
Post by: Lars on July 05, 2022, 09:41:44 am
At least nmake.exe treats all environment variables as makefile variables (unless you suppress this via a commandline switch).
Therefore, you can do this (from an nmake makefile):

rc -r -i $(UNIXROOT)\usr\include walker.rc

Maybe the same thing works for make.exe.