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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:44:23+00:00 2026-05-28T18:44:23+00:00

I was happily coding, thinking that everything was alright, until.. libtool: link: g++ -g

  • 0

I was happily coding, thinking that everything was alright, until..

libtool: link: g++ -g -O2 -o bbcp bbcp-main.o bbcp-server.o bbcp-client.o bbcp-client_manager.o bbcp-bbcp.pb.o -pthread  -lconfig++ /usr/lib/libprotobuf.so -lz -lpthread -lglog -L/usr/lib -lboost_thread-mt -lboost_system -pthread
bbcp-client_manager.o: In function `BBCP::Server::ClientManager::send_message(boost::shared_ptr<BBCP::Server::Client>, BBCP::Protocol::Message const&)':
/home/eax/BBCP/src/client_manager.cpp:63: undefined reference to `void BBCP::Server::Client::sendPacket<BBCP::Protocol::Message>(BBCP::Protocol::PacketType, BBCP::Protocol::Message const&)'
collect2: ld returned 1 exit status

This not so happy error made me clueless…

client_manager.cpp:

void BBCP::Server::ClientManager::send_message(BBCP::Server::client_ptr client, BBCP::Protocol::Message const &message) {
    google::protobuf::RepeatedPtrField<BBCP::Protocol::Destination> destinations = message.destination();
    BBCP::Protocol::Destination *tmp;
    BBCP::Protocol::Message msg = message;
    std::string tmp_nickname;
    client_ptr tmp_target;
    int x;

    if (!msg.has_sender() || msg.destination_size() == 0) {
        return;
    }

    for (x = 0; x < msg.destination_size(); ++x) {
        tmp_nickname = (destinations.Get(x)).nickname();

        if ((tmp_target = get_nickname(tmp_nickname))) {
            msg.clear_destination();
            tmp = msg.add_destination();
            tmp->set_nickname(tmp_nickname);

            tmp_target->sendPacket<BBCP::Protocol::Message>(BBCP::Protocol::SINGLE_MESSAGE, msg); // this is the line of the error
        }
        else {
            client->sendError(BBCP::Protocol::DESTINATION_UNKNOWN, tmp_nickname);
        }
    }

    return;
}

client_ptr equals to boost::shared_ptr<BBCP::Server::Client>.

Then we have client.cpp:

template<class T>
void BBCP::Server::Client::sendPacket(enum BBCP::Protocol::PacketType type, T const &packet) {
    std::vector<unsigned char> pbuffer;
    BBCP::Protocol::Header header;

    header.set_type(type);
    header.set_length(packet.ByteSize());
    pbuffer.resize(BBCP_HDR_MSG_SIZE + packet.ByteSize());

    if (!header.SerializeToArray(&pbuffer[0], BBCP_HDR_MSG_SIZE)) {
        LOG(ERROR) << "Header of type " << type << " and length " << packet.ByteSize() << " failed to serialize to array. Send aborted.";
    }
    else if (!packet.SerializeToArray(&pbuffer[BBCP_HDR_MSG_SIZE], packet.ByteSize())) {
        LOG(ERROR) << "Packet of type " << type << " and length " << packet.ByteSize() << " failed to serialize to array. Send aborted.";
    }
    else {
        boost::asio::async_write(*socket, boost::asio::buffer(&pbuffer[0], pbuffer.size()), boost::bind(&BBCP::Server::Client::sendPacketWriteHandler, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
    }

   return;
}

This function is defined the same way in BBCP::Server::Client as a public member.

As always, any help will be appreciated.

Julian.

  • 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-28T18:44:25+00:00Added an answer on May 28, 2026 at 6:44 pm

    Definition of [member] function templates in C++ sources is OK as long as you explicitly instantiate the template in the corresponding source file. Just having the member function template defined in a source and used in a different source won’t work. You can try adding something like this after the the definition of the member function template:

    template void BBCP::Server::Client::sendPacket<BBCP::Protocol::Message>(
        BBCP::Protocol::PacketType, BBCP::Protocol::Message const &packet);
    

    Of course, this assume that BBCP::Protocol::Message is defined at this point.

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

Sidebar

Related Questions

Until a week ago I was happily coding html.erb files in Notepad++ with syntax
I was happily coding, thinking I'd not run into problems anymore (for now, at
I was happily using outline property until I came to know that it is
Up until yesterday I have been happily connecting to SQL Server Express 2005 using
I had been happily coding along on a decent sized solution (just over 13k
I noticed today (after ~8 years of happily hacking away at bash) that there
I've been very happily using PredicateBuilder but until now have only used it for
I am very happily using git-svn, though I noticed that git has a different
I came across this recently, up until now I have been happily overriding the
We have a windows service that has been happily running in production for over

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.