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 6907021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:23:01+00:00 2026-05-27T08:23:01+00:00

In my GUI application (MFC) I am using a dll to display something in

  • 0

In my GUI application (MFC) I am using a dll to display something in the screen. I have a static library which having a singleton class for this.
eg: sing.lib. I am including sing.lib in application (exe) project and in dll project(coz both uses this singleton class)

Issue is the instance getting in exe and in dll is different. Both calls the constructor!!
see the singleton class code snippet.

class A
{
private:
    A();
    virtual ~A();
    static A* m_pInstance;
public:
    static A* GetInstance()
    {
        if (NULL == m_pInstance)
        {
            m_pInstance = new A();
        }
        return m_pInstance;
    }
}
  • 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-05-27T08:23:02+00:00Added an answer on May 27, 2026 at 8:23 am

    If you want the singleton instance to be shared between dll and exe, place its definition in a dynamic link library instead of static library.

    In general if you want some data to be global and unique you should not put it in static library.

    Consider

    //static lib
    
    int CurrentCounter =0;
    
    int getNextCounter()
    {
        return CurrentCounter;
    }
    

    such a code in static library. In your case if both the exe and dll link against this library each will get its own CurrentCounter. So exe and dll can have different values of CurrentCounter at the same time.

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

Sidebar

Related Questions

I have a win32 GUI (MFC) application which I need to port to a
I have a normal Windows GUI application (made using the API, not MFC) and
I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
I'm writing a GUI application in Python using wxPython and I want to display
I have a GUI application, which creates a QProcess inside, catches its output and
I have a GUI application which includes a number of icons used for toolbar
I'm working on updating the GUI of a native (MFC) application using .NET and
I have a GUI application. In my main class I have a method (called
This is a GUI application (actually MFC). I need a command window with the
Which standalone Windows GUI application do you recommend for use for accessing a Subversion

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.