Sign in to follow this  
Juskelis

Learning Visual C++ 2012

Recommended Posts

So I'm a computer science major learning in C++, but my school doesn't teach us using Visual Studio. I know how to do a lot of the basics of programming, so instead I'm looking more for how to do advanced stuff with Visual Studio.

 

Namely how to deal with adding my own libraries to a project and getting them to work, or more generally anything involving the Project Properties window. Do you guys know anywhere that can teach me how to do that?

Share this post


Link to post
Share on other sites

To include a static library to an existing project you need to do the following:
* Add the include path(s) to the library's headers.
* Add the library path to the library itself.

These are done in the project configuration tab.
* Add the library ("foo.lib") to the "Linker - Additional libraries" box

This should in theory be it, but you may run into linker errors if:
* The library in question requires other libraries to be included.
* The library was built in a different configuration than your project (I think this is Windows-only. /MDd or /MD flags needs to be same for both)

There are probably other considerations to be made, that other posters can supply.

Share this post


Link to post
Share on other sites

To include a static library to an existing project you need to do the following:
* Add the include path(s) to the library's headers.
* Add the library path to the library itself.

These are done in the project configuration tab.
* Add the library ("foo.lib") to the "Linker - Additional libraries" box

This should in theory be it, but you may run into linker errors if:
* The library in question requires other libraries to be included.
* The library was built in a different configuration than your project (I think this is Windows-only. /MDd or /MD flags needs to be same for both)

There are probably other considerations to be made, that other posters can supply.

 

So if I were to add foo.lib to my project using that, would I need to move the library to somewhere special? Or could I just do the full path to foo.lib?

 

 

You can add the include headers and library path to the VC++ Directories tab in the solution configuration, that way you dont have to provide fulll path to any of the inluded headers or library files.

 

I like that idea. Do I just edit the library directories field in there? Just out of curiousity, what's the Library WinRT Directories?

Share this post


Link to post
Share on other sites

It's only a rather small portion of the book, but the part of Game Coding Complete goes through a bit of project setup before diving into coding (see the start of Ch4). It sets up external libraries, changes output directories for a cleaner solution directory, etc.

 

 

To include a static library to an existing project you need to do the following:
* Add the include path(s) to the library's headers.
* Add the library path to the library itself.

These are done in the project configuration tab.
* Add the library ("foo.lib") to the "Linker - Additional libraries" box

This should in theory be it, but you may run into linker errors if:
* The library in question requires other libraries to be included.
* The library was built in a different configuration than your project (I think this is Windows-only. /MDd or /MD flags needs to be same for both)

There are probably other considerations to be made, that other posters can supply.

 

So if I were to add foo.lib to my project using that, would I need to move the library to somewhere special? Or could I just do the full path to foo.lib?

It just has to be in one of the library directories you specified in the previous step. Not sure how VS handles two files with the same name in different directories, though.

 

If you want an example of someone including libraries/directories/etc, you could look up an example of including DirectX in a version of VS pre-2012. A quick Google search gives this example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this