Author Topic: Compiling PM app on 2016.  (Read 36478 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Compiling PM app on 2016.
« 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.

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.
« Last Edit: May 31, 2016, 05:10:42 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Compiling PM app on 2016.
« Reply #1 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.

Mike La Martina

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Compiling PM app on 2016.
« Reply #2 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #3 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1317
  • Karma: +26/-0
    • View Profile
Re: Compiling PM app on 2016.
« Reply #4 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.

Mike La Martina

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
    • View Profile
Re: Compiling PM app on 2016.
« Reply #5 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #6 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 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 give me the following error.
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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4787
  • Karma: +99/-1
    • View Profile
Re: Compiling PM app on 2016.
« Reply #7 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.

Michaelhz

  • Guest
Re: Compiling PM app on 2016.
« Reply #8 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
« Last Edit: June 01, 2016, 08:16:18 am by Michael Holzapfel »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #9 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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Michaelhz

  • Guest
Re: Compiling PM app on 2016.
« Reply #10 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

Lars

  • Hero Member
  • *****
  • Posts: 1271
  • Karma: +65/-0
    • View Profile
Re: Compiling PM app on 2016.
« Reply #11 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.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #12 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

Thanks for the help.

I will try to keep forward with this book samples.

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4713
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #13 on: July 14, 2016, 04:05:08 am »
Hi

I want to compile the Chapter 04 samples, but these samples uses the Linker and MAKE. There is also the "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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

RickCHodgin

  • Guest
Re: Compiling PM app on 2016.
« Reply #14 on: July 14, 2016, 03:46:46 pm »
Hi

I want to compile the Chapter 04 samples, but these samples uses the Linker and MAKE. There is also the "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