Sign in to follow this  

Visual Studio 2005 - unmanaged C++ project reference

This topic is 2841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, This is really a Visual Studio question but it may be useful in game development projects as well. I have a kind of "framework" built on top of DirectX. It is implemented in one of the projects in my VS solution. I would like to reuse this framework within other projects in the same solution. In managed languages (C#, VB.NET) I simply reference other projects but how to do that in the unmanaged environment? My environment: Visual Studio 2005 unmanaged C++ DirectX 9.0 Thanks, Leszek

Share this post


Link to post
Share on other sites
There are 2 main ways of reusing a framework.

The potentially easiest is to just add all the source to the new project. For small projects this is often acceptable, but for more robust reusability you should create a library.

To create and use a library, you first need to move the framework in to it's own project with the output type configured as a static library instead of application. In projects which you want to use this library you need to add the directory containing the header files to the "Additional Include Directories" list, the directory containing the lib files to the "Additional Library Directories" list, and finally add the library filename to "Additional Dependencies". This needs to be done for both Debug and Release (they have separate lists).

"Additional Include Directories" is found in the project properties under "C/C++"->"General"

"Additional Library Directories" is found in the project properties under "Linker"->"General"

"Additional Dependencies" is found in the project properties under "Linker"->"Input"

The library will then be linked in to your executable binary and you can call functions in the library as though they were in your main project.

Share this post


Link to post
Share on other sites
Drakonite said:
>just add all the source to the new project

This is what I'm trying to avoid. I don't want to duplicate the framework code in each and every project in my solution.

>you should create a library
Yep, it seems so. I just hoped there would be an easier method of "sharing" my framework among all other projects within the solution.

>you first need to move the framework in to it's own project
It is in its own project - the one I want to share.

I found in MSDN these step-by-step instructions how to create library projects (both DLL and static).

Walkthrough: Creating and Using a Dynamic Link Library:
http://msdn.microsoft.com/en-us/library/ms235636(VS.80).aspx

Walkthrough: Creating and Using a Static Library:
http://msdn.microsoft.com/en-us/library/ms235627(VS.80).aspx

... I just thought it would be possible to "share" the source code so I could step into the framework code from a debugger. I guess I can't jump into a library as it is a compiled piece of code.

Thanks,
Leszek

Share this post


Link to post
Share on other sites
You can step in to a library if you have the source for it. Typically the way to set it up is you include the project for your library in the solution. Then add linker settings for the library and build dependencies for projects that depend on it. You should be able to step in to the library seamlessly(as long as the lib is built with debug symbols).

Share this post


Link to post
Share on other sites

This topic is 2841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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