4

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?

NeoFahrenheit
  • 347
  • 5
  • 16

2 Answers2

7

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.

rjkrocks
  • 87
  • 10
  • you are welcome :). Can you mark this as resolved, then? It would help someone else. Regards... – rjkrocks Jul 06 '17 at 16:39
  • I can confirm it also worked for me in VS2015. I appreciate the link. – Letokteren Jul 12 '17 at 20:13
  • 4
    Note that in recent revisions of the PDCurses, the folder is changed. So we need to make slight changes to the directories and names. The win32 is changed to wincon and the visual c compiler make file is no Makefile.vc instead of vcwin32.mak – rjkrocks Apr 20 '18 at 17:28
  • When I tried to configure visual studio 2017 with the settings described above, I could not find the setting “Runtime Library” in step 3 under “C/C++” section. I tried compiling anyway and it did not work. Can someone please help? – Alex Wang Nov 23 '18 at 07:56
  • @AlexWang , did you visited the properties of the project? (you can access it from the menu "Project" or right click your project name and then you should see project properties. Then in the "Configuration Properties" section go to C/C++, then you will able to see "CodeGeneration" tab. And follow the instructions. All the best. – rjkrocks Jan 31 '19 at 16:34
  • I have also sometimes observed that C/C++ option in the project property may not be visible if we haven't ever tried to compile the project. So give it a try. If you can't find the C/C++ option, then skip to the next step, and continue. Try compiling the code. – rjkrocks Apr 03 '19 at 15:08
  • I have also tested this for Visual Studio 2019 and it is found working. – rjkrocks Apr 03 '19 at 15:08
  • I must be a retard. I tested this and even though pdcurses.lib is added to the linker, the library and include paths are set, I get a linker error for the various pdcurses functions I try to call. This is happening in VS2017 :-/ – OOPMan Apr 17 '19 at 20:32
  • @OOPMan: What kind of functions? Is it happening for all the functions? Are you trying to use the unicode functions, which have wide character support? In this case, have you enabled the wide character support, when compiling the library? – rjkrocks Apr 18 '19 at 13:50
  • @rjkrocks I worked out my problem. It was due to the calling convention setting in my VS2017 project. It seems the pdcurses compiles with cdecl but my project (a WinUSB template) was using stdcall. Changing to cdecl fixed the issue. – OOPMan Apr 19 '19 at 18:11
3

This is old news now, but it might help somebody to know that pdcurses is packaged up on vcpkg.

To use it, (assuming you have vcpkg installed, of course, (Installing vcpkg) )

vcpkg install pdcurses

and you're off to the races. vcpkg will take care of making sure the include and library paths are all set.