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

Martin Iturbide

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

I tried your files, I removed the old files and just leave the files on "slider_b2.zip"

I tested first your "slider.exe" file and it works. Finally I saw how the program should look like.

I did a "make clean" and run compile.cmd.  On this case I remain using wrc on the makefile.
It gave me this error and the generated slider.exe is not working.

Quote
[C:\DEV\DEV-SAMPLES-PM-SLIDER]make   2>&1  | tee make.out
gcc -Wall -Zomf -O2 -c slider.c -o slider.obj
gcc -Zomf slider.obj slider.res slider.def -o slider.exe
Compile ending.
RC is reading the binary resource file C:\dev\DEV-SAMPLES-PM-Slider\slider.res.

RC :Warning 3014: RC found a resource type equal to zero.
RC :Error 1003:RC had an I/O error with file .

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


FYI: I don't use ilink.exe, I'm using the wl.exe linker.

I thought that to change from wrc to rc.exe was just to change the makefile, is something else I need to change?

Should it be that I may be missing some .h file? I don't know why SLIDER.DEP makes reference to fclsldp.h. I don't have that .h on hard drive.

My enviroment is very simple and I just have this:
Quote
SET INCLUDE=C:\usr\include\os2tk45\inc;C:\usr\include\os2tk45\gl;C:\usr\include\os2tk45;C:\USR\INCLUDE
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK

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

Martin Iturbide

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

FOUND MY ISSUE.

It was something with my environment. I removed the OS2TK45 (RPM) completely from my dev system.

My config.sys was.

Quote
SET LIB=C:\USR\LIB
SET INCLUDE=C:\USR\INCLUDE
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK

Tested all the other samples, WALKER2, BITCAT, VECTFONT. All compiled and worked without problems.

Returned to "SLIDER", compile it and I get this error:

Quote
[C:\DEV\DEV-SAMPLES-PM-SLIDER]make   2>&1  | tee make.out
gcc -Wall -Zomf -O2 -c slider.c -o slider.obj
gcc -Zomf slider.obj slider.res slider.def -o slider.exe
emxomfld: rc: No such file or directory
make: *** [slider.exe] Error 1

So, I guess that comparing SLIDER to the other samples, this one compiles in a way I need to specify the RC.
I added ...
 SET EMXOMFLD_RC_TYPE=WRC
 SET EMXOMFLD_RC=wrc.exe

Now it works.

Regards
« Last Edit: April 28, 2023, 06:19:26 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #32 on: April 28, 2023, 10:31:50 pm »
Hi

I moved on with the next sample: PM Running Box.
- https://github.com/OS2World/DEV-SAMPLES-PM-PM_running_Box

It compiled very easy, it works as expected and warnings were removed.

I just got this warning that I don't know about:

Quote
gcc -Wall -Zomf -c -O2 run.c -o run.obj
gcc -Zomf run.obj run.def -o run.exe
Warning! W1058: file ldSBPZPt.: line(20): protmode option not valid for an OS/2 EMX executable

Regards
« Last Edit: April 28, 2023, 10:34:18 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #33 on: April 28, 2023, 11:49:27 pm »
Quote
gcc -Wall -Zomf -c -O2 run.c -o run.obj
gcc -Zomf run.obj run.def -o run.exe
Warning! W1058: file ldSBPZPt.: line(20): protmode option not valid for an OS/2 EMX executable

Easy, it was the "protmode" that was on the .DEF, I just removed since it was empty.
No more warning for this one.

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5041
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #34 on: April 29, 2023, 01:58:17 am »
Yea, the protmode one is weird. Everyone used it with link386/ilink, which never complained and the documentation hints that it is needed for protected mode programs. Meanwhile wlink complains about it and it seems that it is actually an OS/2 1.x thing, or maybe 16 bit thing.
Quote
Syntax: PROTMODE

This statement specifies that the module runs only in protected mode and not in Windows or dual mode. This statement is always optional and permits a protected mode only application to omit some information from the executable file header.

If this statement is not included in the module definition file, LINK386 assumes the application can be run in either real or protected mode.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #35 on: April 29, 2023, 02:54:01 am »
Thanks Dave

Now I want to try another sample.
https://github.com/OS2World/DEV-SAMPLES-PM-LBoxFont

I had  corrected some warnings, did some changes (I hope I didn't break anything) but I'm stuck in these errors.

Code: [Select]
gcc -Wall -Zomf -c -O2 app.c -o app.obj
gcc -Wall -Zomf -c -O2 wndproc.c -o wndproc.obj
wndproc.c: In function 'APPWndProc':
wndproc.c:112:9: warning: returning 'int' from a function with return type 'MRESULT' {aka 'void *'} makes pointer from integer without a cast [-Wint-conversion]
  112 |  return TRUE;
      |         ^~~~
gcc -Wall -Zomf -c -O2 appcmd.c -o appcmd.obj
appcmd.c: In function 'APPCommand':
appcmd.c:22:7: warning: 'strncpy' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation]
   22 |       strncpy (temp, "Window", index2);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
appcmd.c:27:7: warning: 'strncpy' output truncated before terminating nul copying 7 bytes from a string of the same length [-Wstringop-truncation]
   27 |       strncpy (temp, "PM Land", index2);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc -Wall -Zomf -c -O2 apppaint.c -o apppaint.obj
gcc -Zomf app.obj app.def -o app.exe
weakld: error: Unresolved symbol (UNDEF) 'APPCommand'.
weakld: info: The symbol is referenced by:
    C:/dev/DEV-SAMPLES-PM-LBoxFont/APP.DEF
weakld: error: Unresolved symbol (UNDEF) 'APPWndProc'.
weakld: info: The symbol is referenced by:
    C:/dev/DEV-SAMPLES-PM-LBoxFont/APP.DEF
    C:\dev\DEV-SAMPLES-PM-LBoxFont\app.obj
weakld: error: Unresolved symbol (UNDEF) 'EditDlg'.
weakld: info: The symbol is referenced by:
    C:/dev/DEV-SAMPLES-PM-LBoxFont/APP.DEF
weakld: error: Unresolved symbol (UNDEF) 'About'.
weakld: info: The symbol is referenced by:
    C:/dev/DEV-SAMPLES-PM-LBoxFont/APP.DEF
weakld: error: Unresolved symbol (UNDEF) '_FontMetrics'.
weakld: info: The symbol is referenced by:
    C:\dev\DEV-SAMPLES-PM-LBoxFont\app.obj
Ignoring unresolved externals reported from weak prelinker.
emxomfld: ignoring SEGMENTS directive in .def-file
emxomfld: ignoring SEGMENTS directive in .def-file
emxomfld: ignoring SEGMENTS directive in .def-file
emxomfld: ignoring SEGMENTS directive in .def-file
Error! E2028: APPWndProc is an undefined reference
Error! E2028: About is an undefined reference
Error! E2028: APPCommand is an undefined reference
Error! E2028: EditDlg is an undefined reference
Error! E2028: _FontMetrics is an undefined reference
Error! E2044: exported symbol APPWndProc not found
Error! E2044: exported symbol About not found
Error! E2044: exported symbol APPCommand not found
Error! E2044: exported symbol EditDlg not found
make: *** [app.exe] Error 1

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5041
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #36 on: April 29, 2023, 03:44:57 am »
Well with these changes it compiles, but doesn't run, leaving an entry in popuplog
Code: [Select]
--- APP.DEF.orig        2023-04-28 18:29:06.000000000 -0700
+++ APP.DEF     2023-04-28 18:30:02.000000000 -0700
@@ -2,22 +2,10 @@

 DESCRIPTION 'OS/2 Presentation Manager Application - Skeleton'

-STUB    'OS2STUB.EXE'
-
 CODE                    MOVEABLE
 DATA                    MOVEABLE MULTIPLE

-SEGMENTS
-        APP_TEXT        PRELOAD MOVEABLE DISCARDABLE
-        WNDPROC_TEXT    PRELOAD MOVEABLE DISCARDABLE
-        APPCMD_TEXT     LOADONCALL MOVEABLE DISCARDABLE
-        APPPAINT_TEXT   MOVEABLE DISCARDABLE
-
 HEAPSIZE  2048
 STACKSIZE 4096

-EXPORTS
-        APPWndProc      @1
-        About           @2
-        APPCommand      @3
-        EditDlg         @4
+
Code: [Select]
--- makefile.orig       2023-04-28 18:31:14.000000000 -0700
+++ makefile    2023-04-28 18:43:36.000000000 -0700
@@ -7,7 +7,8 @@
 all : app.exe

 app.exe : app.obj wndproc.obj appcmd.obj apppaint.obj app.res app.def
-       gcc -Zomf app.obj app.def -o app.exe
+       gcc -Zomf app.obj wndproc.obj appcmd.obj apppaint.obj app.res \
+          app.def -o app.exe
        wrc app.res

 app.obj : app.c app.h

Being a 16 bit OS/2 program, perhaps it needs more porting?
Edit: This gets rid of one warning
Code: [Select]
--- WNDPROC.C.orig      2023-04-28 18:52:40.000000000 -0700
+++ WNDPROC.C   2023-04-28 18:51:42.000000000 -0700
@@ -109,7 +109,7 @@
         break;

     case WM_ERASEBACKGROUND:
-       return TRUE;
+       return (MRESULT) TRUE;
        break;

     case WM_DRAWITEM:
« Last Edit: April 29, 2023, 03:54:15 am by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5041
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #37 on: April 29, 2023, 04:02:27 am »
OK, better def to make it not crash,
Code: [Select]
NAME           APP  WINDOWAPI

DESCRIPTION     '@#OS2World:1.01#@##1## 28 Apr 2023 17:01:00     ARCAOS-507::::::v1.01@@App test'
HEAPSIZE       1024
STACKSIZE      8192

Bldlevel copied from one of your other defs
Edit: I think the truncated strings were truncated on purpose, probably there is a better way to code it.
Edit2: Or bad programming? This gets rid of the error but I'm not sure if it correct
Code: [Select]
--- APPCMD.C.orig       2023-04-28 19:12:48.000000000 -0700
+++ APPCMD.C    2023-04-28 19:12:02.000000000 -0700
@@ -18,12 +18,12 @@
 {


-                   index2 = strlen ("Window");
+                   index2 = strlen ("Window") + 1;
                    strncpy (temp, "Window", index2);
                    temp [index2] = '\0';
                    WinSendMsg (hwndList, LM_INSERTITEM, MPFROM2SHORT (LIT_SORTASCENDING, 0),
                                MPFROMP (temp));
-                   index2 = strlen ("PM Land");
+                   index2 = strlen ("PM Land") + 1;
                    strncpy (temp, "PM Land", index2);
                    temp [index2] = '\0';
« Last Edit: April 29, 2023, 04:15:22 am by Dave Yeo »

Martin Iturbide

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

It compiles and runs now. Not sure if the program is doing all that it should, but it put strings on the list box.

I think Im publishing this one on github and move to other sample.

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

Martin Iturbide

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

RandRect demo also compiles and runs as expected. I removed the warnings and it is available at:
https://github.com/OS2World/DEV-SAMPLES-PM-RANDRECT

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4997
  • Karma: +44/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #40 on: April 29, 2023, 03:58:15 pm »
Hi

After fixing the warnings I also have "Checkers Board" sample compiling on gcc 9.
An interesting remark here is that it used the old "Profile Manager" functions WinQueryProfileData and WinWriteProfileData that was changed for PrfQueryProfileData and PrfWriteProfileData

https://github.com/OS2World/DEV-SAMPLES-PM-Checkers_Board

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

Martin Iturbide

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

I moved along with Air_Traffic_Control_Container
https://github.com/OS2World/DEV-SAMPLES-PM-Air_Traffic_Control_Container

After some fixing it compiles and runs, but I need a hand with these warnings.

Quote
gcc -Wall -Zomf -c -O2 atccnr.c -o atccnr.obj
atccnr.c: In function 'InsertContainerRecords':
atccnr.c:437:50: warning: pointer targets in initialization of 'unsigned char *' from 'char *' differ in signedness [-Wpointer-sign]
  437 |     static const PSZ apszCallSignPrefixes [] = { "AA", "DA", "UA", "TW" };
      |                                                  ^~~~
atccnr.c:437:50: note: (near initialization for 'apszCallSignPrefixes[0]')
atccnr.c:437:56: warning: pointer targets in initialization of 'unsigned char *' from 'char *' differ in signedness [-Wpointer-sign]
  437 |     static const PSZ apszCallSignPrefixes [] = { "AA", "DA", "UA", "TW" };
      |                                                        ^~~~
atccnr.c:437:56: note: (near initialization for 'apszCallSignPrefixes[1]')
atccnr.c:437:62: warning: pointer targets in initialization of 'unsigned char *' from 'char *' differ in signedness [-Wpointer-sign]
  437 |     static const PSZ apszCallSignPrefixes [] = { "AA", "DA", "UA", "TW" };
      |                                                              ^~~~
atccnr.c:437:62: note: (near initialization for 'apszCallSignPrefixes[2]')
atccnr.c:437:68: warning: pointer targets in initialization of 'unsigned char *' from 'char *' differ in signedness [-Wpointer-sign]
  437 |     static const PSZ apszCallSignPrefixes [] = { "AA", "DA", "UA", "TW" };
      |                                                                    ^~~~
atccnr.c:437:68: note: (near initialization for 'apszCallSignPrefixes[3]')
atccnr.c:485:30: warning: format '%ld' expects argument of type 'long int', but argument 4 has type 'int' [-Wformat=]
  485 |         sprintf (szBuf, "%s%ld", apszCallSignPrefixes [rand() % cPrefixes],
      |                            ~~^
      |                              |
      |                              long int
      |                            %d
  486 |      rand() % 1000);
      |      ~~~~~~~~~~~~~           
      |             |
      |             int

And as a extra thing, I want to also generte the .HLP file on the makefile, so I have some questions.
1) Is there any open source alternative to ipfc.exe
2) Is ipfc.exe available on the RPM? if so, which package has it?

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5041
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #42 on: April 29, 2023, 05:31:09 pm »
Hi Martin, there is wipfc,
Code: [Select]
G:\WATCOM\binp>wipfc.exe
Open Watcom OS/2 Help Compiler Version 2.0beta4 Limited Availability by GKYMar2 2022
Copyright (c) 2010 Open Watcom Contributors. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
The 'WIPFC' environment variable needs to be set. It should contain the name of
the directory containing .nls and entity.txt

No experience with it besides that others use it and it mostly works fine.
Edit: os2tk45-ipfc.rpm contains all the files for ipfc, *.aps, ibmdic.dic and the nls files and of course ipfc.exe
« Last Edit: April 29, 2023, 05:48:41 pm by Dave Yeo »

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5041
  • Karma: +114/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #43 on: April 29, 2023, 06:10:38 pm »
This patch compiles the help file,
Code: [Select]
--- makefile.orig       2023-04-29 09:11:40.000000000 -0700
+++ makefile    2023-04-29 09:08:46.000000000 -0700
@@ -4,7 +4,7 @@
 #  Compile::Watcom Resource Compiler
 #  Compile::GNU C
 #  Make: nmake or GNU make
-all : atccnr.exe
+all : atccnr.exe atccnr.hlp

 atccnr.exe : atccnr.obj help.obj atccnr.res atccnr.def
        gcc -Zomf atccnr.obj help.obj atccnr.res atccnr.def -o atccnr.exe
@@ -19,5 +19,8 @@
 atccnr.res : atccnr.rc jet.ico
        wrc -r atccnr.rc

+atccnr.hlp: atccnr.ipf
+       ipfc atccnr.ipf
+
 clean :
-       rm -rf *exe *RES *obj
\ No newline at end of file
+       rm -rf *exe *RES *obj *HLP

And one warning down, not sure about the signedness ones.

Code: [Select]
--- atccnr.c.orig       2023-04-29 09:06:48.000000000 -0700
+++ atccnr.c    2023-04-29 09:07:00.000000000 -0700
@@ -482,7 +482,7 @@
         pacrTraverse->AssignedHeading  = rand() % 360 + 1;
         pacrTraverse->Speed         =
         pacrTraverse->AssignedSpeed = rand() % 20 + 10;
-        sprintf (szBuf, "%s%ld", apszCallSignPrefixes [rand() % cPrefixes],
+        sprintf (szBuf, "%s%d", apszCallSignPrefixes [rand() % cPrefixes],
                                        rand() % 1000);
         pacrTraverse->pszCallsign   = (PSZ) strdup (szBuf);

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 359
  • Karma: +24/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #44 on: April 29, 2023, 08:56:45 pm »
And one warning down, not sure about the signedness ones.

All these signed/unsigned character warnings can be resolved by adding "-DOS2EMX_PLAIN_CHAR" to the compiler flags. See 'os2emx.h' for details.