OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Martin Iturbide on May 31, 2016, 04:23:54 pm

Title: Compiling PM app on 2016.
Post by: Martin Iturbide on May 31, 2016, 04:23:54 pm
Hi

I want to compile (just compile) some basic examples of the OS/2 PM Programming  book from Charles Petzold, but I was wondering on which tools to compile it. It is the most basic example that does not do anything called W.C (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP02).

The C sample came with the MAK file for IBM C Dev Workset/2 (icc) and Borland C++ (bcc), but I would not want to use them since they are too old. I will like to ask (in my complete ignorance about this topic) which should be the modern way to compile a PM application? which are the tools that I should install to compile PM source code trying to be focused on open source tools and non-dead compilers if possible.... or the only way is to use an old IBM-unsupported compiler?

My other question is if a similar environment of Paul's Dev can be installed using ANPM (or RPM/YUM) because I don't want to have some conflicts with files, can the full dev environment can be installed with RPM/YUM? or does the netlabs repo may be missing some tools? If it is possible I will like to have the list of package required to be installed.

According to the text I will have to use, MAKE or NMAKE, ICC or BCC and LINK386 or TLINK, but I will like to use open source ones if it is possible. My guess is I can use GNU MAKE, GCC but no idea what is the open source linker, please correct me if I'm wrong.

Please notice this will be my first try to compile something on OS/2, I simple don't know much about it.

Regards

Update: Added link for the W.C sample (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP02).
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on May 31, 2016, 04:50:08 pm
Your choices are OpenWatcom, which does have an IDE and is sorta still alive and open source or GCC probably along with make, though you can just do gcc -o hello.exe hello.c, use batch files or other makes. Linker options include ld.exe (ours is so old it is GPL v1 with RMS as primary authour), wlink, the OpenWatcom linker, which is preferred as we the source and Steven has checkin rights, or the IBM linkers.
SD386 on Hobbes is an open source debugger though IBM seems to have forgot a license when they open sourced it.

For your first try, you might want to install OpenWatcom and try the IDE. There is also the "Programming OS/2 Warp for Dummies" book.
Ask here for advice on compile flags etc.
Title: Re: Compiling PM app on 2016.
Post by: Mike La Martina on May 31, 2016, 07:29:41 pm
I don't understand your comment Martin.  I use the IBM Visual Age C++ product almost every day, and it still works.
In fact I have compiled Petzolds programs with C/Set 2 in the past and that also worked.
What do you mean the compilers are too old?
I still compile 16 bit OS/2 programs with the Microsoft C600 compiler.  Family API applications work well with it, as well as PM applications.
I don't understand the age of product being any impediment to development on a platform that has not fundamentally changed since these products were new.
I have had problems with the Watcom debugger that I don't have with the VA debugger.  But its your choice.
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on May 31, 2016, 07:45:48 pm
Thanks Dave.

I will try OpenWatcom. I'm starting right now with gcc. I noticed I have it installed with RPM/YUM. I'm running it with the W.C example but I'm not sure yet if I'm doing the right steps to compile it. Since this initial samples does not do anything, I'm not sure if it just executing "gcc -o W.EXE W.C" is all I have to do. Gcc does not give errors, but I'm not sure if the .EXE is producing is working.

Hi Mike.
For me (personal opinion) it is important to try to move away from discontinued/close source applications and try to use open source replacements if it can be possible on the platform. It does not mean for me that VisualAge it is bad or good product, but it is not available on the market anymore, it is hard for people to have access to it (it is not longer for sale and need to be found on ebay) and it is not an active product or open source that can be improved. Like you said it is thing of choice, I prefer to don't use a dead compiler even if the open one is more limited or harder to use.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Dariusz Piatkowski on June 01, 2016, 01:24:06 am
Martin,
Do you have the OS/2 Warp Toolkit installed? Either way the linker, make, etc are part of that install. Also, you will need the OS/2 header files...so I'm guessing you'd pretty much need the toolkit installed first.

For my part, I took a stab at this stuff a good 3-4 yrs ago, I have VAC++ and IBMC C/C++ 3.65 installed, my preference was to use 3.65 and like Mike commented never had a problem with this approach for the rather non-complex pieces of code I was building.

I ran all my stuff through VisualSlickEdit, which uses the idea of project definitions...so you end up building the *.cmd files to run the specific EXEs to compile, link, etc..

Happy to post my details if you wish to pursue this option.
Title: Re: Compiling PM app on 2016.
Post by: Mike La Martina on June 01, 2016, 02:10:00 am
Yes Martin you are correct that Visual Age is no longer available as well as the other compilers I mentioned.
I have had these tools for so long that I forget that others may not.
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on June 01, 2016, 03:04:42 am
Hi

For the moment I'm just trying with gcc installed from RPM/YUM.
But is it complete necessary to install the OS/2 toolkit to compile an PM application?

Checking the samples it compiles W.C, WE.C, WEL.C, WELC.C and WELCO.C (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP02) and generates the exe file.... the file seems to work, the program does not does anything as supposed to, but I included some "printf" around to send some messages on the command prompt and it worked.

But compiling WELCOM.C (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/blob/master/CHAP02/WELCOM.C) give me the following error.
http://www.os2world.com/wiki/index.php/Draft_Notes_about_PM_Compiling (http://www.os2world.com/wiki/index.php/Draft_Notes_about_PM_Compiling)

But please notice that I'm compiling it the most basic way I can, I really do not know if I'm doing it right, of I should do some other steps before or create some CMD script to prepare the PATH/LIBPATH of the environment.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on June 01, 2016, 05:42:05 am
You can compile a PM program with just the libc headers, which include their own version of os2.h which can load os2emx.h or the toolkit headers. The toolkit headers are generally better and some programs such as MPlayer need them (to pull in the 4cc stuff).
Looks like GCC is not happy doing the conversion and probably needs a cast, newer GCCs are picky.
You also have to include os2.h correctly by defining some things, depending on what functions you're using. The toolkit docs are the source of exactly what. Generally this will work
Code: [Select]
#define INCL_BASE
#define INCL_PM
#include <os2.h>

You should also use the -Zomf flag to link to native libs.
Code: [Select]
gcc -Zomf -o WELCOM.EXE WELCOM.C
GCC actually outputs aout object code, an ancient format and can use emxomf to convert it to the native OMF format.
Title: Re: Compiling PM app on 2016.
Post by: Michael Holzapfel on June 01, 2016, 07:51:34 am
Hm... exactly followed the setup recommended for compiling VirtualBox (see Build instructions from http://trac.netlabs.org/vbox).
Then downloaded  samples from Charles Petzolds PM-Book (ftp://ftp.charlespetzold.com/OS2PM2/) and compiled welcome.c by the following w/o any modification:

C:\HOME\DEFAULT\DOWNLOADS\PMBOOK\CHAP02]gcc -o welcome2.exe welcome.c welcome.def

Hope this helps
Michael
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on June 01, 2016, 07:45:41 pm
Thank you very much.

It worked for me too using "gcc -o welcome2.exe welcome.c welcome.def" without any change to the source code and only using the development environment that can be installed with RPM/YUM/ANPM.  It seems that .def does something after all :)  ....I need to keep reading.

Thanks also for the link on how the vbox dev environment is installed. I did not installed the OS/2 toolkit or any other extra dev tool outside RPM/YUM yet, which was good for the objective of this little sample.

I will keep reading the book and checking this samples to understand those better. After that I will check out the other chapters and let you know.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Michael Holzapfel on June 02, 2016, 10:48:26 am
The module definition file provides the attribute WINDOWAPI to ensure that the program will start in a PM session.

See also http://www.edm2.com/index.php/Calling_PM_from_AVIO_Applications.

Michael
Title: Re: Compiling PM app on 2016.
Post by: Lars on June 04, 2016, 08:39:53 am
I seem to remember that OpenWatcom comes with all toolkit header files and also import libraries.
That means: you should be able to compile and link a PM application with OpenWatcom without requiring anything else.
The nice thing about OpenWatcom is the IDE. That should make it easier for users to set up a development project.
But of course, if a makefile already exists then it might be easier to just use the compiler/linker that is used in the makefile.
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 04, 2016, 06:32:25 pm
Hi

I just created a very quick article about this forum thread.

* Compiling "OS/2 Presentation Manager Programming" Samples on 2016 (http://www.edm2.com/index.php/Compiling_%22OS/2_Presentation_Manager_Programming%22_Samples_on_2016)

Thanks for the help.

I will try to keep forward with this book samples.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 14, 2016, 04:05:08 am
Hi

I want to compile the Chapter 04 samples (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP04), but these samples uses the Linker and MAKE. There is also the "SYSVALS.MAK (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/blob/master/CHAP04/SYSVALS.MAK)".

I guess I can use "link" command that is on the GNU Coreutils, but I have no idea if there is a make program available on the RPM repos.

Any tips on how to compile this sample? Which commands should I need to run to generate the exe? or how should I modify the MAK file.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on July 14, 2016, 03:46:46 pm
Hi

I want to compile the Chapter 04 samples (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP04), but these samples uses the Linker and MAKE. There is also the "SYSVALS.MAK (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/blob/master/CHAP04/SYSVALS.MAK)".

I guess I can use "link" command that is on the GNU Coreutils, but I have no idea if there is a make program available on the RPM repos.

Any tips on how to compile this sample? Which commands should I need to run to generate the exe? or how should I modify the MAK file.

Regards

Are you trying to compile through the OS/2 port of GCC?  It should have a make utility.  It may not be compatible with the one that toolset was written for, but it should exist.

If it doesn't exist, I can write one for you.

Best regards,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on July 14, 2016, 04:36:29 pm
Our Gnu Make is installed as "yum install kbuild-make" and there is nmake in the toolkit and as an optional install on old Warp.
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 15, 2016, 02:37:35 pm
Thanks Dave. I will be trying it today.

I will also check this simple tutorial (http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/) to see if I can make the .mk file run.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 15, 2016, 02:41:13 pm
Are you trying to compile through the OS/2 port of GCC?....

Yes Rick.

My goal is try to use as much as open source compilers and tools to test the samples of the "OS/2 PM Programming"  book from Charles Petzold.

I will be trying GNU MAKE that is on  "kbuild-make" RPM and the LINK program that is also on the GNU tools ported to OS/2.  If I get stuck I may use something from the OS2Toolkit, but let see if I can pull this samples with open source first.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Andy Willis on July 15, 2016, 04:29:19 pm
Are you trying to compile through the OS/2 port of GCC?....

Yes Rick.

My goal is try to use as much as open source compilers and tools to test the samples of the "OS/2 PM Programming"  book from Charles Petzold.

I will be trying GNU MAKE that is on  "kbuild-make" RPM and the LINK program that is also on the GNU tools ported to OS/2.  If I get stuck I may use something from the OS2Toolkit, but let see if I can pull this samples with open source first.

Regards

You would probably be better off using wmake from open watcom, and consequently just using OW entirely, than make as wmake has a switch to make it nmake compatible.  wmake will work with gcc if you desire but OW is open source so would fit you desires in that regard.
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on July 15, 2016, 06:37:41 pm
You would probably be better off using wmake from open watcom, and consequently just using OW entirely, than make as wmake has a switch to make it nmake compatible.  wmake will work with gcc if you desire but OW is open source so would fit you desires in that regard.

+1.  /I/ appreciate that information too, Andy.  Thank you.

Best regards,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 15, 2016, 10:54:15 pm
Hi

I have no idea how to use the make command.

For the SYSVALS sample (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP04) I was guessing it was as simple as:
Code: [Select]
make SYSVALS.MAK

But I get
Quote
make: Nothing to be done for `SYSVALS.MAK'.

I modified SYSVALS.MAK like this:

Code: [Select]
#------------------------
# SYSVALS.MAK make file
#------------------------

PRGCC=gcc
PRGLINK=link


sysvals.exe : sysvals.obj sysvals.def
     $(PRGLINK) sysvals, sysvals, NUL, sysvals

sysvals.obj : sysvals.c sysvals.h
     $(PRGCC) sysvals.c


Any tips?

Regards
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on July 16, 2016, 02:50:26 am
Hi

I have no idea how to use the make command.

For the SYSVALS sample (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP04) I was guessing it was as simple as:
Code: [Select]
make SYSVALS.MAK

But I get
Quote
make: Nothing to be done for `SYSVALS.MAK'.

I modified SYSVALS.MAK like this:

Code: [Select]
#------------------------
# SYSVALS.MAK make file
#------------------------

PRGCC=gcc
PRGLINK=link


sysvals.exe : sysvals.obj sysvals.def
     $(PRGLINK) sysvals, sysvals, NUL, sysvals

sysvals.obj : sysvals.c sysvals.h
     $(PRGCC) sysvals.c


Any tips?

Regards

The make utility is designed to handle the variable compilation of a system by looking at what files have changed, and then only compiling minimally the requirements of the project.  If you have ten .c files which create ten .obj files, and of those ten .c files some of them have dependencies on other .h files, then whenever a .h file is changed, it will recompile anything that will be affected by that change.

In the example you post here, it may be saying that the .obj files are already built, and that the .exe file is already built, and that nothing has changed, so there is nothing to do.

If you load sysvals.c or sysvals.h into a text editor, and simply re-save it, and then run make, it may recompile and rebuild.

Best regards,
Rick C. Hodgni
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on July 16, 2016, 03:50:15 am
make --help is your friend, Usually make will automatically use a file named makefile. In this case you have to point at the makefile, make -f SYSVALS.MAK.
You should use PRGLINK=gcc and gcc will call the correct linker, ld by default or with the -Zomf flag emxomfld, which, depending on environment variables (run emxomfld with no arguments to see the variables) will invoke wlink, ilink or link386 with the correct arguments.
Title: Re: Compiling PM app on 2016.
Post by: Gregg Young on July 26, 2016, 05:17:48 am
Martin

If you are serious about helping to maintain or port software I think you need to install Open Watcom for maintaining OS/2 software and need  GCC for porting. Open Watcom has been forked. There is a 2.0 version of the fork that has an OS/2 version but that version doesn't contain the latest OX/2 code. The unforked version is still at 1.9 which lacks Steve Levine's debug and high memory updates and lacks wipfc. I would recommend you install the unforked 1.9 and highly recommend if you or anyone else is interested I have a build of the latest code which I can provide as a zip file you can unzip over the i1.9 install.

As for GCC, Paul Smedley offers a copy of his build environment for a small donation either by mail on a DVD or via download (note it is huge). This gives you a very complete environment. If you want to stick with what is available from yum. You should also download the open watcom linker (on the netlabs rpm site) and make sure GCC is setup to use it as the linker (it is the most capable and advanced linker that runs on OS/2). Obviously if you get the latest Open Watcom from me you can forgo the download and just use the OW linker (wl) from the OW install.
Title: Re: Compiling PM app on 2016.
Post by: Andi B. on July 26, 2016, 09:37:29 am
Quote
The unforked version is still at 1.9 which lacks Steve Levine's debug and high memory updates and lacks wipfc.
Is this still true for the nightly builds from the current perforce repository? I don't think so but I'm not sure.

Frank regularly builds whole package from the official source. Last drop is from May 28, 2016. It is called 2.0 too.

The unofficial fork at sourceforge does have some nasty bugs and is not very well tested. So I don't want to recommend it but the official one build by Frank or by yourself from the perforce repository instead.
Title: Re: Compiling PM app on 2016.
Post by: Mentore on July 26, 2016, 12:46:42 pm
Martin

If you are serious about helping to maintain or port software I think you need to install Open Watcom for maintaining OS/2 software and need  GCC for porting. Open Watcom has been forked. There is a 2.0 version of the fork that has an OS/2 version but that version doesn't contain the latest OX/2 code. The unforked version is still at 1.9 which lacks Steve Levine's debug and high memory updates and lacks wipfc. I would recommend you install the unforked 1.9 and highly recommend if you or anyone else is interested I have a build of the latest code which I can provide as a zip file you can unzip over the i1.9 install.

Hello Gregg,
I'm interested in your updated 1.9 version. How can I obtain it?

If you need to email me just contact me at mentore dot siesto at alice dot it.

Thanks in advance!
Mentore
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on July 28, 2016, 02:17:30 am
Hi Gregg, Andi W.

I'm going very slow on this subject. For the moment I only want to learn to compile some samples. On the past my stopper was that it was very elaborated to install the development environment, this is why I'm trying to do it as quick as possible with RPM/YUM this time.

I will try OpenWatcom on the future, but I will go very slow with this.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Lars on July 30, 2016, 07:29:36 pm
1) use ANPM to install these packages: gcc, gcc-wlink, gcc-wrc. Alternatively you can run "yum install gcc gcc-wlink gcc-wrc" from a commandline.

2) Make sure these lines are in config.sys or add them if they are not. Fix the drive letter to your system and make sure you have the OS/2 toolkit installed (the below setup will use the OS/2 toolkit for all headers instead of what comes in usr/include. The reason is that what comes in usr/include is not complete with regard to what the toolkit offers):
SET GCCOPT=-static-libgcc -DUSE_OS2_TOOLKIT_HEADERS -Zomf
SET C_INCLUDE_PATH=D:/USR/INCLUDE;D:/OS2TK45/H
SET LIBRARY_PATH=D:/USR/LIB
SET EMXOMFLD_RC=wrc.exe
SET EMXOMFLD_RC_TYPE=WRC
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK

3) this is how you then compile a file:
gcc -c -Wall

4) this is how you link together multiple files (and create a map file) and link to libs lib1 and lib2
gcc -Zmap -o myexe.exe lib1 lib2 foo1.o foo2.o

There are variations to the compiler flags: add -O if you want optimization or -g if you want to debug etc.
You should just know that what is set in GCCOPT appends to what you specify as switches to gcc.exe.
I did it this way because there are things that you always would need to set, for example the -Zomf switch
(for the compilation as well as for the linking stage).

5) change your makefile so that it uses the switches for compiling and linking as given above.

6) instead of using nmake.exe you could also use make:
use ANPM and install kbuild-make or run "yum install kbuild-make" from the commandline
However that means you will need to change the makefile syntax and structure to what make accepts. I recommend some book.
The documentation of nmake.exe however is available in the OS/2 toolkit.

One last thing: the above setup will allow you to source code debug executables built with gcc to operate under the VAC debugger or various other debuggers that use the HLL debug format. This is the standard debug format that any of IBM's debuggers use (VAC debugger, SD386, ICAT, etc.). I would hope that even the Watcom debugger can debug this format but I haven't tried and I am not sure.

Lars

Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on July 30, 2016, 10:07:01 pm
On top of what Lars posted (good advice), I'd also add this to config.sys
Code: [Select]
SET SHELL=sh.exe
SET EMXSHELL=sh.exe
SET CONFIG_SHELL=sh.exe
SET MAKESHELL=sh.exe
SET EXECSHELL=sh.exe
[code]
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on August 13, 2016, 08:56:27 pm
Thanks for the tips but I'm still stuck on the samples of Chapter 04 (https://github.com/OS2World/DEV-SAMPLES-PM-PM_Programing/tree/master/CHAP04).

My goal is to make that sample compile with gcc if it is possible.

Since I got stuck with the "make" command, I'm trying to see if it just compiles with a single command line (no idea if it is possible).
I also installed OS2TK45 with RPM YUM and added to the config.sys what Lar's suggested.

I'm trying  "gcc -o sysvals.exe sysvals.c sysvals.def sysvals.h" it gaves me a lot of errors and warnings and I can not capture them all. Maybe it is something very basic to capture the errors but I don't know how to do it. I'm trying "gcc -o sysvals.exe sysvals.c sysvals.def sysvals.h >out.txt" but it generated an empty file.

I also tried "gcc -Zmap -o sysvals.exe sysvals.c sysvals.def sysvals.h" with the same results.

So I'm stuck, any other tip is welcome.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on August 13, 2016, 09:17:18 pm
Try
Code: [Select]
gcc -Ix:/path/to/includes -Zomf -o sysvals.exe sysvals.c sysvals.def 2>&1 | tee out.txt

note that the order might need changing and if the .h file is in the current directory then -I. might be good enough. -I tells gcc where to find the includes (.h files)
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on August 13, 2016, 11:50:11 pm
Hi, thanks for the help Dave.

I have sysvals.c sysvals.def sysvals.h on the same folder. Does it means that "gcc -I -Zomf -o sysvals.exe sysvals.c sysvals.def 2>&1 | tee out.txt" should be enough?

It give me this error:

Code: [Select]
weakld: error: Unresolved symbol (UNDEF) '_min'.
weakld: info: The symbol is referenced by:
    C:\var\temp\cc1VpZ1e.o
weakld: error: Unresolved symbol (UNDEF) '_max'.
weakld: info: The symbol is referenced by:
    C:\var\temp\cc1VpZ1e.o
Ignoring unresolved externals reported from weak prelinker.
Warning! W1058: file ldMNdPE7.: line(21): protmode option not valid for an OS/2 EMX executable
Error! E2028: _max is an undefined reference
Error! E2028: _min is an undefined reference
file C:\var\temp\cc1VpZ1e.o(cc1VpZ1e.o): undefined symbol _max
file C:\var\temp\cc1VpZ1e.o(cc1VpZ1e.o): undefined symbol _min
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on August 14, 2016, 02:40:51 am
-I. Note the dot to show the current directory. Ignore the protmode error or remove the line from the DEF file. The other errors might be fixed by the -I. more likely there is a missing library or macro.
Hmm, seems that min and max macros are defined in the toolkits stdlib.h but not in the kLIBC stdlib.h. Not sure about the best way to use the toolkits stdlib.h so simplest to add the macro.
Add
Code: [Select]
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
to sysvals.c, at about line 14, so you have
Code: [Select]
#include <stdlib.h>
#include <string.h>
#include "sysvals.h"

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))

MRESULT EXPENTRY ClientWndProc (HWND, ULONG, MPARAM, MPARAM) ;
LONG             RtJustCharStringAt (HPS, PPOINTL, LONG, PCHAR) ;
and test.
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on August 14, 2016, 04:40:52 pm
Thanks Dave.

I compiled it with "gcc -I. -Zomf -o sysvals.exe sysvals.c sysvals.def 2>&1 | tee out.txt" after adding the lines to define the variables. It compiled with a warning.

Code: [Select]
Warning! W1058: file lduse9IK.: line(21): protmode option not valid for an OS/2 EMX executable
But the program is running, I will keep trying some other samples.

Regards
Title: Re: Compiling PM app on 2016.
Post by: Martin Iturbide on August 14, 2016, 07:12:28 pm
Hmm, seems that min and max macros are defined in the toolkits stdlib.h but not in the kLIBC stdlib.h. Not sure about the best way to use the toolkits stdlib.h so simplest to add the macro.

Should I open a ticket for stdlib.h to be updated on the KLIBC project? Does it makes sense?

Regards
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on August 14, 2016, 07:43:29 pm
Good question. I'm not really sure. Might be better to just use the toolkits version of stdlib.h.
I did
Code: [Select]
set C_INCLUDE_PATH=g:/os2tk45/h/libc and tested,
Quote
In file included from sysvals.c:10:0:
g:/os2tk45/h/libc/stdlib.h:545:1: error: stray '\32' in program
In file included from sysvals.c:11:0:
g:/os2tk45/h/libc/string.h:379:1: error: stray '\32' in program
I then removed the CTRL-Z from the tail of the .h files and it compiled fine with only the protmode warning from wlink.
How did RPM/YUM install the toolkit? Mine is an old manual install. Perhaps test by setting the C_INCLUDE_PATH and seeing if the unpatched source compiles and whether the CTRL-Z EOF (end of file) error happens.
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on August 14, 2016, 08:01:25 pm
Added -Wall (turn on all warnings) to the gcc command line, gcc -I. -Wall -Zomf -o sysvals.exe sysvals.c sysvals.def 2>&1 | tee out.txt and lots of warnings, mostly about types not exactly matching.
Title: Re: Compiling PM app on 2016.
Post by: Lars on August 14, 2016, 08:51:26 pm
Hmm, seems that min and max macros are defined in the toolkits stdlib.h but not in the kLIBC stdlib.h. Not sure about the best way to use the toolkits stdlib.h so simplest to add the macro.

Should I open a ticket for stdlib.h to be updated on the KLIBC project? Does it makes sense?

Regards

No it makes no sense as "min" and "max" macros are not ANSI compliant and therefore not required.
In reality, most compiler's header files supply these macros as they are used so often. But ANSI does not define them ...

Lars
Title: Re: Compiling PM app on 2016.
Post by: Paul Smedley on August 14, 2016, 10:12:19 pm
Hmm, seems that min and max macros are defined in the toolkits stdlib.h but not in the kLIBC stdlib.h. Not sure about the best way to use the toolkits stdlib.h so simplest to add the macro.

Should I open a ticket for stdlib.h to be updated on the KLIBC project? Does it makes sense?

No it makes no sense as "min" and "max" macros are not ANSI compliant and therefore not required.
In reality, most compiler's header files supply these macros as they are used so often. But ANSI does not define them ...

klibc sys/param.h has:
/*
 * minimum and maximum macros. Use available g++ tricks.
 */
#if defined(__cplusplus) && (__GNUC__ >= 2) && (__GNUC__ <= 3)
# define MIN(a, b)      ( (a) <? (b) )
# define MAX(a, b)      ( (a) >? (b) )
#else
# define MIN(a, b)      ( (a) < (b) ? (a) : (b) )
# define MAX(a, b)      ( (a) > (b) ? (a) : (b) )
#endif
so
#define min MIN
#define max MAX

should also work.... (assuming sys/param.h gets loaded somewhere)
Title: Re: Compiling PM app on 2016.
Post by: Lars on August 16, 2016, 05:43:59 pm
In this case it will not work as Martin is not compiling C++ code but rather C code.
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on May 28, 2017, 11:37:53 pm
I don't understand your comment Martin.  I use the IBM Visual Age C++ product almost every day, and it still works.
In fact I have compiled Petzolds programs with C/Set 2 in the past and that also worked.
What do you mean the compilers are too old?
I still compile 16 bit OS/2 programs with the Microsoft C600 compiler.  Family API applications work well with it, as well as PM applications.
I don't understand the age of product being any impediment to development on a platform that has not fundamentally changed since these products were new.
I have had problems with the Watcom debugger that I don't have with the VA debugger.  But its your choice.

Mike, can you help me get started on an actual existing OS/2 development platform?  I have downloaded Visual Age for C++ 4.0, and I'm using Arca OS.  I also have older tools which may work in Win-OS/2 such as Visual C++ 98 which has an early version of Microsoft's IDE.

I'm okay using the command line, or a graphical IDE... I just need some help getting started on the existing tools for OS/2.

Thank you,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: Dave Yeo on May 29, 2017, 03:54:31 am
There's OpenWatcom, OpenWatcom.org (http://OpenWatcom.org), the only existing cross compiler for OS/2 and of course GCC, yum install gcc.
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on May 29, 2017, 05:16:07 am
There's OpenWatcom, OpenWatcom.org (http://OpenWatcom.org), the only existing cross compiler for OS/2 and of course GCC, yum install gcc.

Thank you, Dave.  I had some difficulty installing Visual Age C++ because I had to reboot after various stages.  I haven't done that in an OS for a while and it threw me for a loop. :-)

Once I got it installed I was stunned.  Visual Age C++ is amazing considering its age.

I'll take a look at OpenWatcom, and gcc.  I am familiar with gcc on Linux and Windows (mingw).

Thank you,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: Mike La Martina on May 29, 2017, 05:24:24 am
Rick:
I will be glad to help if I can.  As I said in my previous post I use Visual Age C++ V3.8 for both C and C++ development.
I have used the IBM class libraries and ObjectPM from Secant Technologies.  I don't think they are around anymore, but I did find their class libraries easy to use and fun.

Let me know how I may be of assistance.
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on May 29, 2017, 06:42:32 am
Rick:
I will be glad to help if I can.  As I said in my previous post I use Visual Age C++ V3.8 for both C and C++ development.
I have used the IBM class libraries and ObjectPM from Secant Technologies.  I don't think they are around anymore, but I did find their class libraries easy to use and fun.

Let me know how I may be of assistance.

Thank you, Mike.  I'm getting the three developer environments setup and everything's going smoothly so far.  I'm thoroughly impressed with Arca OS's new release.

Thank you,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: André Heldoorn on May 29, 2017, 10:02:10 am
OpenWatcom.org, the only existing cross compiler for OS/2

I'm pretty sure that, for example, at least one of the Pascal environments, Virtual Pascal, is capable of producing code for more than one OS. FWIW.

IBM VAC++ 3.08 FixPaks: FTP-server service.software.ibm, com, directory /ps/products/visualagecpp/fixes/v30os2/english-us/fixpak8
Title: Re: Compiling PM app on 2016.
Post by: Andreas Kohl on May 29, 2017, 12:47:17 pm
There's OpenWatcom, OpenWatcom.org (http://OpenWatcom.org), the only existing cross compiler for OS/2 and of course GCC, yum install gcc.
OpenWatcom supports different host OS and some more target OS in one package. For older OS/2 32-bit releases version 1.8 of OpenWatcom C/C++ should be used. Support for other target architectures is almost not existing, only an assembler for Alpha AXP and PowerPC. On the other hand it includes enough libraries to produce simple PM applications.

IBM C compilers are cross-platform as defined in SAA CPI C Level 2. With later products that introduced new C and C++ features it becomes more complicated. But projects based on IBM's class library could be exchanged between VisualAge C++ 3.0 for OS/2 and VisualAge C++ 3.5 for Windows. IBM C/C++ Compilers V3.6 were available for AIX, OS/2 and Windows NT. For compiling 16-bit object code IBM C/2 (or MS C 6.0) is still needed additionally.

Title: Re: Compiling PM app on 2016.
Post by: Dariusz Piatkowski on May 29, 2017, 02:23:33 pm
Hi Rick,

...I had some difficulty installing Visual Age C++ because I had to reboot after various stages.  I haven't done that in an OS for a while and it threw me for a loop. :-)

Once I got it installed I was stunned.  Visual Age C++ is amazing considering its age...

Which version of VAC did you install?

I am asking b/c I have the fully blown 4.0 here (with various fixpacks) and as you said, even though the product is aged now it is still extremely impressive. Considering that it was always resource hungry, now with the faster machines and better hardware capability it really zips along quite nice.

Part of that install, in my case, was the option to select the standard C/C++, which I did, thus installing the 3.6.5 release (or maybe it was a separate install altogether??? lol, it's been a while...).

What I have always wondered about is the choice between the two? Which one is best suited for what types of apps?
Title: Re: Compiling PM app on 2016.
Post by: Rick C. Hodgin on May 29, 2017, 04:50:07 pm
Hi Rick,

...I had some difficulty installing Visual Age C++ because I had to reboot after various stages.  I haven't done that in an OS for a while and it threw me for a loop. :-)

Once I got it installed I was stunned.  Visual Age C++ is amazing considering its age...

Which version of VAC did you install?

I am asking b/c I have the fully blown 4.0 here (with various fixpacks) and as you said, even though the product is aged now it is still extremely impressive. Considering that it was always resource hungry, now with the faster machines and better hardware capability it really zips along quite nice.

Part of that install, in my case, was the option to select the standard C/C++, which I did, thus installing the 3.6.5 release (or maybe it was a separate install altogether??? lol, it's been a while...).

What I have always wondered about is the choice between the two? Which one is best suited for what types of apps?

It was Visual Age for C++ Version 4.0.  I had not had anything previously installed on this machine.  It was a brand new Arca OS installation, and I was going through the install.exe on the CD image I created.

What was confusing me was I had to reboot after a few stages.  I also wonder whether Navigator 4.0 was required since I have newer programs that could support HTML frames.

I am flatly amazed by Visual Age 4.  And I must say, I am also continually impressed by every piece of software I come across by IBM.  I worked at Toyota for three years and when I was given my orientation I was asking them why they used IBM's DB2?  They said it was simple, they deal with 1000s of transactions per second on their manufacturing lines, and they setup the database and did a test.  They had DB2, SQL Server, and several others.  While it was in the middle of the simulation testing environment, the technicians went behind the machines and pulled out the power cord.  They then booted up to see how much damage there was.  The test software had been written to log which writes were identified as "successful" on the server, as was given by a valid return code to the issuing machine used in the test.

IBM's DB2 was the only one that came back up with a 100% retention of data, such that everything that was deemed to be written successful from the application's point of view, was actually in the database with a valid timestamp, etc.

They have used IBM DB2 since that time, and have never had a single problem.  In fact, when I was there, it was the most tolerant part of our entire networking infrastructure.

I give full props and credit to IBM.  Everything I've ever used from them has been grade A++.  From my 1984 IBM PCjr (I got one after the chiclet keyboard, so my experience was a more normal keyboard), to IBM Writing Assistant that came in cartridge form with that computer, through every other piece of software I've used through Warp 4 back in the mid-90s.  And I should add that I mean that in the sense that here in 2017 still looking at the capabilities of that software, its design, etc ... still amazing.

It's an amazing legacy for a company.  And I only wish IBM would've continued development on OS/2 and its follow-ons.  We would all be using either OS/2 today (or some derivative), or we would've all had a much better, much more capable Windows.

In either case, IBM's contribution to our general software world was cut off too soon.  They should've persisted and shown the world what a company bent on doing things correctly in design and implementation was capable of.  They would've notably changed the world and our 2000s would be different because of it.

Thank you,
Rick C. Hodgin
Title: Re: Compiling PM app on 2016.
Post by: Andreas Kohl on May 29, 2017, 06:26:28 pm
I am asking b/c I have the fully blown 4.0 here (with various fixpacks) and as you said, even though the product is aged now it is still extremely impressive. Considering that it was always resource hungry, now with the faster machines and better hardware capability it really zips along quite nice.
I don't know what you mean by "various". There's only Fixpak 1 for OS/2:
ftp://public.dhe.ibm.com/ps/products/visualagecpp/fixes/v40os2/english-us/fixpak1/ (http://ftp://public.dhe.ibm.com/ps/products/visualagecpp/fixes/v40os2/english-us/fixpak1/)

http://www-01.ibm.com/support/docview.wss?uid=swg24000729 (http://www-01.ibm.com/support/docview.wss?uid=swg24000729)

Quote
Part of that install, in my case, was the option to select the standard C/C++, which I did, thus installing the 3.6.5 release (or maybe it was a separate install altogether??? lol, it's been a while...).
It's an extra CD-ROM in the package and needs to be installed separately. Also a different fixpak:
ftp://public.dhe.ibm.com/ps/products/visualagecpp/fixes/v365os2/english-us/fixpak2/ (http://ftp://public.dhe.ibm.com/ps/products/visualagecpp/fixes/v365os2/english-us/fixpak2/)
... and some more fixes:
ftp://public.dhe.ibm.com/ps/products/warpzilla/vacpp365fix.zip (http://ftp://public.dhe.ibm.com/ps/products/warpzilla/vacpp365fix.zip)

ftp://public.dhe.ibm.com/ps/products/warpzilla/vacppoptfix.zip (http://ftp://public.dhe.ibm.com/ps/products/warpzilla/vacppoptfix.zip)

Quote
What I have always wondered about is the choice between the two? Which one is best suited for what types of apps?
V 3.6 is better suited for projects from VAC 3.0 environment or cross platform projects. Of course there is also a migration feature in the V4.0 workframe. Both support the same level of IOC (IBM Open Class).