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

  • Home
  • SEARCH
  • 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 8815389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:21:53+00:00 2026-06-14T04:21:53+00:00

I have created my own blocking queue and I’m having some trouble figuring out

  • 0

I have created my own blocking queue and I’m having some trouble figuring out why I get a linker error (note this is a Qt app in Visual Studio 2010):

#ifndef BLOCKING_QUEUE_H
#define BLOCKING_QUEUE_H

#include <QObject>
#include <QSharedPointer>
#include <QWaitCondition>
#include <QMutex>
#include <queue>

namespace TestingNS
{
    template<typename Data>
    class BlockingQueue
    {
    private:
        std::queue<QSharedPointer<Data>> _queue;
        QMutex _mutex;
        QWaitCondition _monitor;
        volatile bool _closed;

    public:
        BlockingQueue();

        void Close();

        size_t Size();

        void Empty();

        bool IsClosed();

        bool Enqueue(QSharedPointer<Data> data);

        bool TryDequeue(QSharedPointer<Data>& value, unsigned long time = ULONG_MAX);
    };
}
#endif //BLOCKING_QUEUE_H

The implementation is a bit longer, so I have a pastie for it: http://pastie.org/5368660

The program entry point looks like this:

#include <QtCore/QCoreApplication>
#include <QTimer>
#include <iostream>
#include "BlockingQueue.h"

using namespace std;
using namespace TestingNS;

class Item
{

};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    BlockingQueue<Item> queue;

    cout << "Press any key to exit!" << endl;

    char in;
    cin.get(in);
    QTimer::singleShot(0, &a, SLOT(quit()));

    return a.exec();
}

The linker error I get is:

Error   1   error LNK2019: unresolved external symbol "public: __thiscall TestingNS::BlockingQueue<class Item>::BlockingQueue<class Item>(void)" (??0?$BlockingQueue@VItem@@@TestingNS@@QAE@XZ) referenced in function _main

I don’t understand why the linker can’t find the constructor (nor any other method from BlockingQueue). Any ideas?

  • 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-14T04:21:54+00:00Added an answer on June 14, 2026 at 4:21 am

    It’s template, you have to put the implementation inside BlockingQueue.h

    For a while, the standard did
    provide the keyword export to allow such a separate implementation file. But not many
    vendors implemented it. C++11 discontinues that use of export but reserves the export
    keyword for possible future use.)

    Templates have to be used in conjunction with requests for particular
    instantiations of templates.

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

Sidebar

Related Questions

i have created my own Zend_Form class currently just to add some helper functions
I have created my own silverlight API to get/set data from/to MailChimp. It was
I have created my own Attached Property like this: public static class LabelExtension {
I have created my own customized lots of architecture including n-tier layers for different
I have created my own debugger application. It attaches to a process and creates
I have created my own button class called custom_btn. I created it on the
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have created a custom list view, each row has it's own custom selector,
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
I have created own AMI and registered it on Amazon EC2. But while AMI

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.