Including files from another project
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Including files from another project

  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Including files from another project

    I'm rather new to Visual Studio, and I have two projects in one solution, Foo and FooTest. In FooTest I've put my unit test classes (using QtTestLib), which will be testing the code in Foo.

    Obviously, this means the unit tests in FooTest need to include header files from Foo. For FooTest, I've set Foo as a project dependency (context menu -> Project dependencies). I've also added Foo as a reference (context menu -> References).

    However, I can't figure out how to actually include the header files from Foo in the FooTest unit test classes. I assume there is some prefix, like #include "Foo/SomeFooClass.h", but I haven't been able to figure out what it is and always end up with a "unresolved external symbol" during linking.

    Can anyone give me a push in the right direction? Thanks in advance!

  2. #2
    Join Date
    Feb 2009
    Location
    India
    Posts
    444

    Re: Including files from another project

    You just need to follow the path from one directory into the other.
    Usually this would be
    #include "../Foo/SomeFooClass.h"

    If you're getting "unresolbved external symbol" error, it is not because of the #include.
    This is a linker error which you get if you do not specify the .LIB file that belongs to the .DLL in the project dependencies.
    _Superman_
    I love work. It gives me something to do between weekends.

    Microsoft MVP (Visual C++)

  3. #3
    Join Date
    Jul 2009
    Posts
    3

    Re: Including files from another project

    Thanks for your reply, Superman. I suppose the problem is that I'm not building a DLL, but an EXE. The only reason I want to use code across the projects is that I'd like to test it.

  4. #4
    Join Date
    Jul 2009
    Posts
    3

    Re: Including files from another project

    How do you people generally organize your test and program code in Visual Studio?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center