Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:00:37+00:00 2026-06-13T11:00:37+00:00

i’m using VS2010, and i am designing a MVC application. Say i have Project

  • 0

i’m using VS2010, and i am designing a MVC application.

Say i have “Project 1” and “Project 2” in a solution. The need to be compiled in that order, P1 compiles to a DLL, P2 to an Exe file that dynamically uses the DLL. P2 declares a view interface. Both projects have a view class that implements the interface (a class with pure virtual methods).

The problem now is, that i cannot include the header file of the interface in P1, because the linker would say then that he cannot resolve this external symbol. Which is of course right, because it is compiled later in P2.

So what i did is, i added the include folder for P2 to P1 and included the interface.cpp in P1 instead of the header file.

It works, but i don’t think this is what i am supposed to do. Or isn’t it? The interface is obviously compiled twice, once in each project.

I don’t want to move the interface to P1, what would solve the problem. Just assume, i don’t want that.

Thanks for input.

edit: code snippet:

Project1:

View1.hpp // nothing special

View1.cpp:

#include ViewInterface.cpp
View1::View1(int x) : ViewInterface(int x)

Project2:

ViewInterface.hpp:

#ifdef EXP
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

class ViewInterface : SomeOtherClass, AnotherClass
{
  virtual void DECLDIR show(void) const = 0;
  virtual void DECLDIR hide(void) const = 0;
}

ViewInterface.cpp:

ViewInterface::ViewInterface(int x) : SomeOtherClass(int x), AnotherClass(int x)

View2.hpp // nothing special

View2.cpp:
#define EXP
#include ViewInterface.h

View2::View2(int x) : ViewInterface(int x)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:00:38+00:00Added an answer on June 13, 2026 at 11:00 am

    I don’t want to move the interface to P1, what would solve the
    problem. Just assume, i don’t want that.

    Then move it to a third entity.

    You have to decide what’s more important to you. If you want a clean solution, then either move the interface definition to the DLL (P1), or to something that both the DLL and the EXE can use – let’s call it “P0”. P0 doesn’t even have to be something that’s compiled – a simple header file in it’s own directory with everything defined inline will do just fine. My preferred choice would be to have P0 be a DLL though.

    That is the only clean solution. The following “solutions” are really just hacks that I describe for sake of completeness.


    If you really want the “dirty” solution, then do the same, with the only difference that you leave the header file defining the interface in the application-source-folder.

    And if you want it ultra-dirty, then include the .cpp file when building the DLL like you suggested. It will also work… it’s just really yuck.

    Of course you do have to be aware of some things. E.g. the “interface” should not have any static data members, and no function in the “interface” should have function local statics. Because if they do, then those static variables will be instantiated twice – once in the DLL and once in the EXE. Also since all code will be compiled into both projects, you have to re-compile both projects if you want to change anything. (The code being duplicated in the DLL and EXE isn’t a problem as long as they were compiled from the same code.)

    Those limitations of course also apply if you choose the “P0 = just a header file” solution.


    And finally there’s the really really bad super-dirty solution: implement the interface in the EXE, dllexport it from the EXE and dllimport it in the DLL (yes, that can be done!). Downside is that you would have to do a special EXE build that only builds the import-library for the EXE (which can be done without having the import library for the DLL). With the import library for the EXE you can then build the DLL, and with the import library for the DLL you can then build the EXE itself.
    That way the “interface” could even have static data members, and if you change only the code (i.e. no changes in the header-files) then you would only have to re-compile the EXE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.