How do I use other libraries in C++? Specifically using the PDCurses library in the latest version of Visual Studio Express? What's the general way to set a libray up, how to use it? Thank you for your time and patience.

Recommended Answers

All 3 Replies

Go to Project --> <Project name> Properties (last menu item) --> Configuration Properties --> Linker --> Input. Then in the right pane, add the lib name in the first item Additional Dependencies.

Under Linker --> General, add the complete path to the lib in Additional Library Directories.

An alternative to the first paragraph above is to use a pragma in one of the *.c or *.cpp files

#pragma comment(lib, "libcurses.lib")

how to use it?

The same way you would use standard C libraries, include the *.h file in the *.c or *.cpp file that is going to use the functions in the library. If you're asking how to use PDCurses I think you will find tutorials if you just google for them.

A warning about using PDCurses -- it is a Windows port of a very very old *nix program which I believe even predates Windows 95. I used it on Unix in the mid 1980s. I don't know how well it works on modern Windows such as Windows 7/8/8.1.

Thank you for your reply! Is it right to say that as long as a library has proper header files and .lib files I can use it without any problems?

When using this

#pragma comment(lib, "libcurses.lib")

where should the libcurses.lib be? and what if it's in another forlder?

I already explained in the second paragraph how to tell the compiler where to find the lib files.

Is it right to say that as long as a library has proper header files and .lib files I can use it without any problems?

Generally, yes, as long as the lib was generated by the same compiler. AFAIK libs generated by GNU and Borland compilers are not compatible with Microsoft compilers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.