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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:23:00+00:00 2026-06-04T08:23:00+00:00

I am trying to build someone else’s code in VS2010. It builds fine in

  • 0

I am trying to build someone else’s code in VS2010. It builds fine in VS2005, but I need to upgrade it.

They have defined a macro as follows in a header:

#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/thread/once.hpp>

#define DEFINE_SINGLETON(name) boost::scoped_ptr<name> Singleton<name>::_instance

template<class T> class Singleton : private boost::noncopyable
{
    public:
        static T& instance() 
        {
            boost::call_once(init, flag);        
            return *_instance;
        }

        static void init()  
        {
            _instance.reset(new T());
        }

    protected:
        Singleton() {}
        ~Singleton() {}

    private:
        static boost::scoped_ptr<T> _instance;
        static boost::once_flag flag;
};

template<class T> boost::once_flag Singleton<T>::flag = BOOST_ONCE_INIT;

I’ve managed to get the code to build now, but I am getting lots of linker errors about this macro:

project1.lib(file1.obj) : error LNK2001: unresolved external symbol "private: static class boost::scoped_ptr<class ClassABC> Singleton<class ClassABC>::_instance" (?_instance@?$Singleton@VClassABC@@@@0V?$scoped_ptr@VClassABC@@@boost@@A)

An example of the macro being used (in source file):

#include "singleton.h"
DEFINE_SINGLETON(ClassABC);

I am quite new to Boost and also to templates (sorry), so I cannot fathom why I’m getting these errors when it all linked fine in VS2005. Its worth noting, that in order to do the upgrade we have also had to upgrade our Boost version, so this could be a factor – a few checks already performed:

  • Header file is included in source file
  • Boost dir is added to include dirs (under VC++ dirs inproperty pages)
  • Added boost lib dir to Linker -> General -> Additional library dependencies

For info, I am compiling a Multi-threaded debug dll on Win32.

I have spent most of the day googling to no avail, so any help greatly appreciated!

Many thanks 🙂

  • 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-04T08:23:02+00:00Added an answer on June 4, 2026 at 8:23 am

    I don’t see you used the macro anywhere in the posted code.

    You need to use it as:

    //add this line after BOOST_ONCE_INIT or before it, or wherever you see fit.
    template<class T> DEFINE_SINGLETON(T);
    

    Personally I would prefer this:

    template<class T> boost::scoped_ptr<T> Singleton<T>::_instance;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to build a legacy code in VS2005 and get errors in VC header
I have a make build system that I am trying to decipher that someone
I am trying to use code written by someone else in my own project.
I'm trying build a MVC framework, but I'm confused about manage themes. Well... I
Trying to build Xuggler under Windows. Xuggler is core native code functions wrapped into
I'm trying to understand InstallShield (2009)/InstallScript on the fly, because I'm modifying someone else's
Does someone know of a good .Net socket sniffer? I'm trying to build an
Using PHP and MySQL, I have a forum system I'm trying to build. What
Below is part of a PHP database class someone else wrote, I have removed
I am trying to build a jigsaw puzzle game in android. Could someone explain

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.