How do we install new libraries for c++ mingw?

18,540

Solution 1

Do you just copy the library files and start using it?

On Windows you should use PDCurses:

Download the zip file, unpack it wherever you typically put external libraries, and check the readme, which tells you the following:

PDCurses has been ported to DOS, OS/2, Win32, X11 and SDL. A directory containing the port-specific source files exists for each of these platforms. Build instructions are in the README file for each platform.

The readme file in the Win32 directory tells you that there are makefiles for several different compilers. In short, you run make:

 make -f makefilename 

It tells mentions a couple of options you can set, including WIDE and UTF8.

To then use the library, add the directory that contains curses.h to your include path and link with the pdcurses.lib file that make generates for you. How you modify your include path and your linked libraries depends on your development environment and is largely irrelevant to PDCurses.

Source How do I install PDCurses in Windows for use with C++? by Rob Kennedy

More detailed instructions below.


So are ncurses and PDcurses the same?

PDCurses (Pubic Domain Curses) is the multi-platform, public domain implementation of the terminal display library NCurses.

NCurses (New Curses) is an implementation of Curses (a play on the term cursor optimization), both of which are terminal control libraries for UNIX and UNIX-like systems.

Although not identical, PDCurses, NCurses, and Curses enable programmers to add mouse support, screen painting, colors, key-mapping, windows, and more to text-based applications without regard to the terminal type. An example of PDCurses in use is shown here.

MingW (Minimalist GNU for Windows) is a minimal Open Source programming environment for developing Windows native applications not requiring 3rd-party Runtime DLLs. However, MingW does utilize some Microsoft DLLs provided by the Microsoft C runtime library. It includes the GNU Compiler Collection (GCC) and associated tools, the GNU binutils.

Source Adding PDCurses to MingW


Adding PDCurses to MingW

Steps

Download the PDCurses version 3.4 file (Download pdc34dllw.zip (86.9 KB)) from Sourceforge.com and unzip it. This version is the Win32 DLL for console with Unicode.

Copy the extracted files to the following folders:

  • pdcurses.lib to MingW's /lib folder
  • curses.h and panel.h to MingW's /include folder
  • pdcures.dll to MingW's /bin folder

Test

Example command using PDCurses to compile the file checkthis.c:

gcc checkthis.c -o checkthis -lpdcurses

If the following code compiles, PDCurses is installed correctly.

/*  checkthis.c  */
#include <curses.h>
int main()
  {
  initscr();
  wclear(stdscr);
  printw("hello world\n");
  wrefresh(stdscr);
  system("pause");
  endwin();
  }

Source Adding PDCurses to MingW

Solution 2

The ncurses library is available for MinGW. Simply open CMD, or run PowerShell and run mingw-get install ncurses, mingw-get will both download and install the package. Just make sure the path to your MinGW bin folder is linked to your system path, and you should be able to use ncurses without trouble.

By the way, be certain to use the -lncurses option when you compile your code.

Share:
18,540

Related videos on Youtube

Allen
Author by

Allen

Updated on September 18, 2022

Comments

  • Allen
    Allen over 1 year

    I wanted to learn about 'ncurses' library.But I am a beginner and couldn't understand how to get the library setup and usable.Do you just copy the library files and start using it or is there something that i should do specifically?

    Thanks in advance.

    • DavidPostill
      DavidPostill over 7 years
      What operating system?
    • Allen
      Allen over 7 years
      I am using mingw in windows 10.
  • Allen
    Allen over 7 years
    So is ncurses and PDcurses the same?Thanks for the help.Also which file do i have to download?There are so may of them.
  • DavidPostill
    DavidPostill over 7 years
    @Allen They are both implementations of curses. There are a few differences. See wmcbrine.com/pdcurses/doc/PDCurses.txt and invisible-island.net/ncurses/ncurses.faq.html for the gory details :)
  • DavidPostill
    DavidPostill over 7 years
  • Allen
    Allen over 7 years
    Ok..i downloaded pdcurs34.zip.Is that the file and do i have to download those dlls
  • DavidPostill
    DavidPostill over 7 years
    @Allen Alternatively ditch mingw and use cywin instead. there are cygwin ncurses and g++ packages
  • DavidPostill
    DavidPostill over 7 years
    The dll's are required at runtime.
  • Allen
    Allen over 7 years
    Sorry if I'm troubling you,but please can you give me a step by step detailed description.I'm not getting it.
  • DavidPostill
    DavidPostill over 7 years
    The instructions are in the answer. I don't have anything else. I don't use mingw or Windows 10.
  • Allen
    Allen over 7 years
  • DavidPostill
    DavidPostill over 7 years
    @Allen Great. I will add it to the answer :)