reference to another project

Posted on 2004-11-24
Last Modified: 2010-04-24
I'm new on Visual and I've got a project under Visual.NET 2002 in unmanaged C++. The project code contained the code for all the tests. It was a problem because even under Release configuration, the tests were compiled and a dll was requested at run-time. As I didn't want the client to install this dll, I created another project in the same solution where I moved the tests.
I tried to compile this new project but it didn't work.
I copied the stdafx from the main project to the new one. There is an improvement but it still doesn't compile. For example, at the line
it doesn't know IDD_AVAILABLE_CODES_DLG. I've tried to copy the .rc and .rc2 files as well as the resource.h but to no avail.

Can someone help me?
Thank you
Question by:__Julien__
    LVL 48

    Expert Comment

    IDD_AVAILABLE_CODES_DLG is defined in resource.h. Ensure that resource.h file is included before dialog h-file. Usullay every cpp file in MFC project has the following include lines:

    #include "stdafx.h"
    #include "MainApp.h"    // Application class h-file, which includes resources.h
    #include "ThisClass.h"   // this class h-file
    // other include lines

    Instead of MainApp.h you can use resources.h:

    #include "staafx.h"
    #include "resource.h"
    #include "ThisClass.h"   // this class h-file
    // other include lines

    In any case, when ThisClass.h is compiled, resource.h is already included.

    Author Comment

    OK, it works but now I've got plenty of "unresolved external references" for all my first project's methods called from my test project. I understand what it means but how can I fix this under Visual ?
    LVL 48

    Accepted Solution

    It's impossible to call methods of one executable file from another. I am trying to undestrand your first post - do you have exe project with some testing code which should be excluded from final Release file? In this case you can use conditional compilation. For example, all test code fragments may be between precompiler directives:

    #ifdef TEST_CODE

    TEST_CODE may be defined in the project settings. You may create various configurations for testing and final release. Or you can add testing code only to debug cobfiguration.

    Another way is moving all tesing code to delay-loaded Dll. If Dll is available at run-time, testing code may be executed. If not (for client release), testing code is not executed. Program can test whether Dll is available using LoadLibrary.
    LVL 48

    Expert Comment

    I am still waiting for __Julien__'s response. Without his feedback I think that my answer is OK.

    Author Comment

    Sorry for the delay, I thought I had already accepted the answer.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now