TSE: How to run the ncurses C library using the Watcom C compiler?

46 views
Skip to first unread message

knud van eeden

unread,
Sep 9, 2023, 7:35:22 AM9/9/23
to SemWare TSE Pro Text Editor
> How to run the ncurses C library using the Watcom C compiler?

ChatGPT

As of my last update in September 2021, the Open Watcom C compiler
does not come with native support for the ncurses library. However, you
may be able to get around this limitation with some workarounds. Here
are some suggestions on how you might attempt to use ncurses with
Watcom C:

===

Download and Build ncurses Source:

1. -Download the source code for ncurses from its official website or other sources.

2. -Configure and build it using gcc (or another compatible compiler),
    which will generate the necessary header files and compiled library
    files (.a or .so).

3. -Configure Watcom:

     Add the headers to Watcom's include path, and the compiled
     libraries to Watcom's library path. This might involve modifying
     environment variables or compiler flags.

4. -Sample Watcom Compilation Command:

You will need to link against the ncurses library while compiling. The
specific command will depend on your setup, but it will generally look
something like this:

--- cut here: begin --------------------------------------------------

wcl386 -I/path/to/ncurses/include -L/path/to/ncurses/lib your_program.c -lncurses

--- cut here: end ----------------------------------------------------

Replace /path/to/ncurses/include and /path/to/ncurses/lib with the actual paths where the ncurses header files and libraries are located.

Check Compatibility:

Note that the ncurses library built with gcc might not be fully
compatible with Watcom C. You might encounter issues with name
mangling, calling conventions, or other binary incompatibilities.

Possible Workaround:

As a workaround, you could consider writing a wrapper library around
ncurses that exposes a simpler, C-compatible API. You should compile
this wrapper library with gcc, then link against it with Watcom. This
could isolate the compiler-specific parts of the code and potentially
allow for better compatibility.

Keep in mind that these are general guidelines and might require
additional work to fit into your specific development environment.

knud van eeden

unread,
Sep 9, 2023, 7:43:41 AM9/9/23
to SemWare TSE Pro Text Editor
Claude2

Here are the steps to run ncurses using Watcom C compiler:

1. -Install Watcom C/C++ compiler. Make sure to also install the ncurses library during the Watcom installation.

2. -Set the environment variables for Watcom:

3. -Set WATCOM to the Watcom install directory

4. -Add %WATCOM%\BINNT to the PATH

5. -Create a C source file (test.c) and include ncurses header:

--- cut here: begin --------------------------------------------------

#include <ncurses.h>

int main() {
  initscr();
  printw("Hello World!");
  refresh();
  getch();
  endwin();
  return 0;
}

--- cut here: end ----------------------------------------------------

Compile the code with Watcom:

--- cut here: begin --------------------------------------------------

wcl386 test.c -lncurses

--- cut here: end ----------------------------------------------------

5.  Run the compiled executable:

This will initialize ncurses, print "Hello World!", wait for a key
press, then end ncurses mode.

The key things are to install ncurses with Watcom, set the environment
correctly, include ncurses header, link with ncurses library, and call
the ncurses functions like initscr(), printw(), etc.

with friendly greetings
Knud van Eeden

knud van eeden

unread,
Sep 9, 2023, 7:47:46 AM9/9/23
to SemWare TSE Pro Text Editor
> How to run the ncurses C library using the Watcom C compiler?

[<Google Bard>]

To run the ncurses C library using the Watcom C compiler, you need to:

1. -Install the ncurses library. You can download the ncurses library from the ncurses website: https://invisible-island.net/ncurses/.

2. -Set the environment variable NCURSES_LOC to the directory where the ncurses library is installed.

3. -Compile your C program with the -lncurses flag.

4. -Run your C program.

5. -Here is an example of how to compile and run a C program that uses
    the ncurses library:

--- cut here: begin --------------------------------------------------

gcc -o hello_world hello_world.c -lncurses

--- cut here: end ----------------------------------------------------

./hello_world

The first line compiles the C program hello_world.c with the -lncurses
flag. The second line runs the compiled program.

Here is the contents of the C program hello_world.c:

--- cut here: begin --------------------------------------------------

#include <ncurses.h>

int main() {
  initscr();

  printw("Hello, world!\n");

  refresh();
  getch();

  endwin();

  return 0;
}

--- cut here: end ----------------------------------------------------

This program simply prints the message "Hello, world!" to the screen.

For more information on how to use the ncurses library, please refer to
the ncurses documentation:

I hope this helps! Let me know if you have any other questions.

knud van eeden

unread,
Sep 9, 2023, 7:55:30 AM9/9/23
to SemWare TSE Pro Text Editor
I created a post on Reddit in the Watcom user group


with friendly greeetings
Knud van Eeden


S.E. Mitchell

unread,
Sep 9, 2023, 8:28:32 AM9/9/23
to sem...@googlegroups.com
Tried this - one cannot link gcc object files with watcom object files.
But, it doesn't really matter, as ncurses does not solve the problem.

If you have a working, tested example, I'm happy to try it.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/semware/1342418170.7241274.1694259318782%40mail.yahoo.com.
Reply all
Reply to author
Forward
0 new messages