views:

209

answers:

2

Hi, I am new to Visual Studio. Need your help with the following.

Visual Studio 2005, VC++
1 solution has 2 projects.
Lets call the solution as 'solution'
Project 1 is named 'p1' and project 2 is called 'p2'
Do I need to export functions and classes from 'p1' so that I can use them by importing in 'p2'?
What if I simply include the header files and then use the functions by calling them straight away?

Thanks, viren

+1  A: 

If I remember correctly (haven't used C++ for a while), there were two different kinds of C++ libraries - a static library (a .lib file) and a dynamic library (a .dll file).

In the case of a static library you had to configure p2 so that it links to p1.lib (in project properties); add p1 to dependancies of p2, so that it is always built first; and then include the .h files from p1 as necessary.

The .dll file was a bit more tricky - the .h files had to have __declspec(dllimport) and __declspec(dllexport) I think. And there was some more magic. Not sure really. But these are the keywords that might get you up and running.

Note that this is a MS specific keyword and will not work on other compilers.

Vilx-
+3  A: 

All you need to do to use these functions is to change the projects dependencies.

Right click on p2(or p1), select "Project Dependencies" Select p1(or p2) and include what you want to use. It's that simple.

David Menard