OS/2, eCS & ArcaOS - Technical > Programming

Compiling a PM sample with GCC

<< < (2/16) > >>

Martin Iturbide:
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.


--- End quote ---

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

Regards

Dave Yeo:
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

Lars:
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 ...

Lars:

--- Quote from: 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: ---        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.

--- End code ---
with this makefile,

--- Code: ---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

--- End code ---

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.

--- End quote ---

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.

Martin Iturbide:
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: ---
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.

--- End code ---


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version