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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:39:44+00:00 2026-06-09T09:39:44+00:00

Linker error messages private: static class Worlds::Game * Worlds::Game::instance The following are the code

  • 0

Linker error messages “private: static class Worlds::Game * Worlds::Game::instance”
The following are the code segments that are related to the error.

From Game.h

static Worlds::Game* instance;
static Worlds::Game* getInstance();

From Game.cpp

Worlds::Game* instance = 0;

Worlds::Game* Worlds::Game::getInstance()
{
    if (instance)
    {
        return instance;
    }
    else
    {
        return instance = new Worlds::Game();
    }
}

So my question is why am I getting this error as I should have all my bases covered for creating a singleton of my game class?

Edit:

I forgot to add in the Game.cpp I have all my Glut Callbacks which need to call the functions in Game that do something.

void onKeyDownCallback(unsigned char key, int mouseX, int mouseY)
void onKeyUpCallback(unsigned char key, int mouseX, int mouseY)
void timerCallback(int value)
void onWindowReshapeCallback(int w,int h)
void onMouseClickedCallback(int button, int state, int mouseX, int mouseY)
void onMouseMovedCallback(int deltaX, int deltaY)
void displayCallback()
  • 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-09T09:39:46+00:00Added an answer on June 9, 2026 at 9:39 am

    static Worlds::Game* instance; – remove this from header. Because instance is marked static it is copied per each translation unit. And you get as many instances as translated units. But you initialize it only in one translation unit

    Also consider implementing a singleton this way:

    Worlds::Game & Worlds::Game::getInstance()
    { 
        static Game instance;
        return instance;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a link error where the linker complains that my concrete class's destructor
Im getting this linker error that won't let me compile. It only happens on
I am getting the following linker error: Undefined symbols for architecture i386: _OBJC_CLASS_$_Message, referenced
Assuming that if the error's spotted in the .o file that it's the linker's
I have the following class: #ifndef CGE_NET_MESSAGE_PARSER_HPP #define CGE_NET_MESSAGE_PARSER_HPP #include Game/platform.hpp #include <vector> #include
I had successfully compiled a static version of qt4.8.2 by following the instructions from
I want a timer class that can post messages to a delegate when there
Unlike this question: Linker Error while building application using Boost Asio in Visual Studio
I'm having a problem with a pesky linker error and would appreciate tips to
relocation truncated to fit: R_X86_64_PC32 against `.bss' I'm getting this linker error in g++

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.