OS/2, eCS & ArcaOS - Technical > Programming

Compiling Tolower tool

(1/3) > >>

Martin Iturbide:
Hi

I want to compile a very simple command line tool called "tolower", that converts the files of a directory to lowercase.

1) I can compile it with it's makefile (nmake) with icc.exe (3.6), but it links the file to the "CPPRSI36.DLL" runtime.
I'm not sure if there is a DLL that came bundled with ArcaOS that can be used to replace the "CPPRSI36.DLL" runtime... like "OS2OM30.DLL"? or it is a completely different thing?


2) I also tried to compile it with gcc just to try it out. I get this error.

--- Quote ---[E:\projects\tolower1]gcc -I. -Zomf -o tolower.exe tolower.c
tolower.c:13:12: fatal error: os2.h: No such file or directory
   13 |   #include <os2.h>
      |            ^~~~~~~
compilation terminated.

--- End quote ---
Where I'm missing to include "C:\usr\include\os2tk45" on the config.sys so gcc can find os2.h ?

Regards

Martin Iturbide:

--- Quote from: Martin Iturbide on February 03, 2021, 01:00:07 am ---1) I can compile it with it's makefile (nmake) with icc.exe (3.6), but it links the file to the "CPPRSI36.DLL" runtime.
I'm not sure if there is a DLL that came bundled with ArcaOS that can be used to replace the "CPPRSI36.DLL" runtime... like "OS2OM30.DLL"? or it is a completely different thing?

--- End quote ---

Hi
I did some guessing, I replaced the "ctype.h" from "D:\IBMCXXO\include" to the one included on the OS2TK45 (D:\OS2TK45\h\libc) and I recompiled.

Now "tolower.exe" did not have dependency on "CPPRSI36.DLL" and seems to be working. I'm not sure if I did the right thing.

Regards

Dave Yeo:
Hi Martin.
I don't know icc much but I'd assume one of the compiler options decides which ctypes.h to use and moving around include files is generally discouraged. I'd read the documentation to see what the options do and it'll likely be obvious which needs changing. One example from EMX was whether to use the single threaded or multi-threaded library. Needed the single threaded library for DOS.
GCC uses its own os2.h in @unixroot/usr/include, which depending on a define (look at os2.h) can use the toolkit or os2emx.h. Usually using the default os2emx.h is fine.
I just compiled it with

--- Code: ---gcc -Zomf tolower.c

--- End code ---
and stupidly converted all the files in my download directory to lowercase :)
Neither GCC or ICC should need the -I. (include current directory) and with the -Zomf, the linker (wl.exe) will produce an executable if you don't tell it otherwise. Hmm, seems that without the -Zomf, ld also now produces an executable too, though much bigger. Used to produce a.out which then needed to be bound to be an executable.

Dave Yeo:
If you want to program, copy tolower.c to to toupper.c and replace tolower with toupper in line 29, change the printf and now you have a program to uppercase file names.
Getting more fancy, you could test the file name and do either depending on name or add a parameter.

Martin Iturbide:
Thanks Dave for the tip. I will also create "toupper" as you suggest for the fun of it.

Dave, by any chance do you know of a good open source example (for OS/2) of a command line tool that can be good to analyze as a "source code skeleton of a command line tool", that may have, multiple input parameters (/s /? etc) and several language support?.

I'm just curious is some sample can be produced as a "source code skeleton of a command line tool" in C.

Regards

Navigation

[0] Message Index

[#] Next page

Go to full version