Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pdcurses on Visual Studio 2017

I was making a 2048 game on Code::Blocks, but due to debugging problems, I move to Visual Studio Community 2017. It seems that conio.h doesn't work there, so I'm trying to switch to curses.h library.

I've read a lot of tutorials, but none of them worked for me. I visited their website and downloaded the .zip file with 384 kilobytes (KB), but I do not know what to do with these files.

Help, please?

like image 274
NeoFahrenheit Avatar asked Jan 05 '23 09:01

NeoFahrenheit


1 Answers

I have found a very useful website which talks about PDCurses and its installation in Visual Studio. Even though it is for 2010/2013, it really worked for me in VS2017 — even the demo programs (with very minute changes)!

So here is the steps I did (since you already have PDCurses):

  1. Take the developer command prompt of VS2017 community edition and type in set PDCURSES_SRCDIR=<PDCurses Directory Location>; in my case it was

    set PDCURSES_SRCDIR=C:\pdcurses-master
    

    Note: Here we are setting up the environment variable needed for compilation. If you need additional functionality defined by the pdcurses library, you may want to set corresponding variables in this step. For example, if you need wide character support, you can use set WIDE=1. To see what all are the options available, you can open up the make file (mentioned in next step) in any text editor and look for if conditionals.

  2. Navigate in the command window to the directory of PDCurses/win32 (in my case C:\pdcurses-master\win32)

    nmake –f vcwin32.mak
    

    (This is the make file for PDCurses.) It will create the pdcurses.lib for our Visual Studio.

  3. Now we need to incorporate the generated library into our project. So open up your project and go to project properties

    • In “VC++ Directories”, change:
      • Include directories: Add a new file-path to PDCurses installation directory, in my case it is C:\pdcurses-master.
      • Library directories: Add a new file-path to PDCurses installation library directory, in my case it is C:\pdcurses-master\win32.
    • In C/C++:
      • In “Code Generation” tab, change “Runtime Library” to “Multithreaded Debug (/MTd)”. (Usually, it is set already)
    • In Linker:
      • In “Input” tab, add pdcurses.lib to Additional Dependencies (I initially got confused - remember, it is the input tab of linker)
    • Click on Apply, and OK.

Then wow! I ran some sample programs (demos) from the pdcurses project and all of them worked for me with very slight modifications.

Note: I created a Windows (also known as Win32, as in Win32 API) console application with Visual Studio 2017 and loaded the project. I did include stdafx.h and compilation was successful and I was able to see the output in the terminal window.

The above website also provides a PDF document too. The instruction there starts from the downloading the pdcurses from website.

like image 68
rjkrocks Avatar answered Mar 16 '23 09:03

rjkrocks