I was making a 2048 game on CodeBlocks, 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 384KB, but I do not know what to do with these files.
Help, please?
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 the pdcurses):
Take the developer command prompt of VS2017 community edition and type in
set PDCURSES_SRCDIR=<PDCurses Directory Location>
; in my case it wasset 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.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 pd curses.) It will create the pdcurses.lib for our Visual Studio.
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
.
- Include directories: Add a new file-path to PDCurses installation directory, in my case it is
- 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 - remeber, it is the input tab of linker)
- In “Input” tab, add
- Click on Apply, and OK.
- In “VC++ Directories”, change:
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 win32 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.
来源:https://stackoverflow.com/questions/42708392/install-pdcurses-on-visual-studio-2017