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

1

2

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.

Allen

Posted 2016-09-07T13:07:32.983

Reputation: 31

What operating system? – DavidPostill – 2016-09-07T14:15:34.133

I am using mingw in windows 10. – Allen – 2016-09-08T14:10:14.447

Answers

0

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

DavidPostill

Posted 2016-09-07T13:07:32.983

Reputation: 118 938

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. – Allen – 2016-09-08T16:02:32.270

@Allen They are both implementations of curses. There are a few differences. See http://wmcbrine.com/pdcurses/doc/PDCurses.txt and http://invisible-island.net/ncurses/ncurses.faq.html for the gory details :)

– DavidPostill – 2016-09-08T16:07:19.547

@Allen Take the latest. https://sourceforge.net/projects/pdcurses/files/latest/download?source=files

– DavidPostill – 2016-09-08T16:09:56.550

Ok..i downloaded pdcurs34.zip.Is that the file and do i have to download those dlls – Allen – 2016-09-08T16:12:03.137

@Allen Alternatively ditch mingw and use cywin instead. there are cygwin ncurses and g++ packages – DavidPostill – 2016-09-08T16:12:12.807

The dll's are required at runtime. – DavidPostill – 2016-09-08T16:15:17.583

Sorry if I'm troubling you,but please can you give me a step by step detailed description.I'm not getting it. – Allen – 2016-09-08T16:40:25.677

The instructions are in the answer. I don't have anything else. I don't use mingw or Windows 10. – DavidPostill – 2016-09-08T16:42:13.600

http://cects.com/adding-pdcurses-to-mingw/ Hey found this. – Allen – 2016-09-08T16:59:55.500

@Allen Great. I will add it to the answer :) – DavidPostill – 2016-09-08T17:01:48.157

0

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.

BTW: be certain to use the -lncurses option when you compile your code.

Cheers...

Benjamin Miller

Posted 2016-09-07T13:07:32.983

Reputation: 1