Install pdcurses on Visual Studio 2017

落爺英雄遲暮 提交于 2019-12-21 18:38:13

问题


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?


回答1:


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):

  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 pd curses.) 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 - remeber, 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 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!