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

Dave Yeo

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

Martin Iturbide

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

Dave Yeo

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4710
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling PM app on 2016.
« Reply #33 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
« Last Edit: August 14, 2016, 07:22:20 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

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

Dave Yeo

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

Dave Yeo

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

Lars

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

Paul Smedley

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

Lars

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

RickCHodgin

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4786
  • Karma: +99/-1
    • View Profile
Re: Compiling PM app on 2016.
« Reply #41 on: May 29, 2017, 03:54:31 am »
There's OpenWatcom, OpenWatcom.org, the only existing cross compiler for OS/2 and of course GCC, yum install gcc.

RickCHodgin

  • Guest
Re: Compiling PM app on 2016.
« Reply #42 on: May 29, 2017, 05:16:07 am »
There's OpenWatcom, 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
« Last Edit: May 29, 2017, 05:19:40 am by Rick C. Hodgin »

Mike La Martina

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

RickCHodgin

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