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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #60 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.

Lars

  • Hero Member
  • *****
  • Posts: 957
  • Karma: +46/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #61 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.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #62 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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #63 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
« Last Edit: June 30, 2022, 04:24:12 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #64 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.
« Last Edit: June 30, 2022, 05:27:00 am by Dave Yeo »

Lars

  • Hero Member
  • *****
  • Posts: 957
  • Karma: +46/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #65 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.

Andreas Schnellbacher

  • Hero Member
  • *****
  • Posts: 796
  • Karma: +14/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #66 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.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #67 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.


Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #68 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
« Last Edit: June 30, 2022, 05:34:43 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 957
  • Karma: +46/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #69 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.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #70 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #71 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 3664
  • Karma: +77/-0
    • View Profile
Re: Compiling a PM sample with GCC
« Reply #72 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #73 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
« Last Edit: July 04, 2022, 03:41:26 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3634
  • Karma: +34/-0
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC
« Reply #74 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.