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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:32:37+00:00 2026-05-24T20:32:37+00:00

I’m getting this error in C++ and I really don’t know how to get

  • 0

I’m getting this error in C++ and I really don’t know how to get to the bottom of it:

g++ proxy.cpp -lboost_thread -lboost_filesystem -lboost_system

/tmp/ccUHa2s3.o: In function `main’:
proxy.cpp:(.text+0x1d8): undefined reference to `server::server(std::deque<boost::shared_ptr<boost::asio::io_service>, std::allocator<boost::shared_ptr<boost::asio::io_service> > > const&, int)‘
collect2: ld returned 1 exit status

I have the following source code (which I copied off http://alexott.net/common/asio-proxy-async/proxy-conn.cpp.html):

//proxy.cpp:
#include "proxy-server.hpp"

int main(int argc, char** argv) {
    try {
        int thread_num=2;
        if(argc > 1)
            thread_num=boost::lexical_cast<int>(argv[1]);
        ios_deque io_services;
        std::deque<ba::io_service::work> io_service_work;

        boost::thread_group thr_grp;

        for (int i = 0; i < thread_num; ++i) {
            io_service_ptr ios(new ba::io_service);
            io_services.push_back(ios);
            io_service_work.push_back(ba::io_service::work(*ios));
            thr_grp.create_thread(boost::bind(&ba::io_service::run, ios));
        }
        server server(io_services);   //apparently there's some error here?
        thr_grp.join_all();
    } catch (std::exception& e) {
        std::cerr << e.what() << std::endl;
    }


    return 0;
}



//proxy-server.hpp:
#ifndef _PROXY_SERVER_H
#define _PROXY_SERVER_H 1

#include "common.h"
#include "proxy-conn.hpp"

#include <deque>

typedef std::deque<io_service_ptr> ios_deque;

class server {
public:
    server(const ios_deque& io_services, int port=10001);

private:
    void start_accept();
    void handle_accept(connection::pointer new_connection, const bs::error_code& error);

    ios_deque io_services_;
    ba::ip::tcp::acceptor acceptor_;
};


#endif /* _PROXY-SERVER_H */


//proxy-server.cpp:
#include "proxy-server.hpp"

server::server(const ios_deque& io_services, int port)
    : io_services_(io_services),
      acceptor_(*io_services.front(), ba::ip::tcp::endpoint(ba::ip::tcp::v4(), port)) {
    start_accept();
}

void server::start_accept() {
    // Round robin.
    io_services_.push_back(io_services_.front());
    io_services_.pop_front();
    connection::pointer new_connection = connection::create(*io_services_.front());

    acceptor_.async_accept(new_connection->socket(),
                           boost::bind(&server::handle_accept, this, new_connection,
                                       ba::placeholders::error));
}

void server::handle_accept(connection::pointer new_connection, const bs::error_code& error) {
    if (!error) {
        new_connection->start();
        start_accept();
    }
}

Can someone please point me in the right direction as to how to fix this error?


Edit

I now get the following error:

g++ proxy.cpp proxy-server.cpp -lboost_thread -lboost_filesystem -lboost_system

/tmp/ccl3DHn7.o: In function `server::handle_accept(boost::shared_ptr<connection>, boost::system::error_code const&)‘:
proxy-server.cpp:(.text+0x250): undefined reference to `connection::start()‘
/tmp/ccl3DHn7.o: In function `connection::create(boost::asio::io_service&)‘:
proxy-server.cpp:(.text._ZN10connection6createERN5boost4asio10io_serviceE[connection::create(boost::asio::io_service&)]+0x29): undefined reference to `connection::connection(boost::asio::io_service&)‘
collect2: ld returned 1 exit status`

  • 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-24T20:32:39+00:00Added an answer on May 24, 2026 at 8:32 pm

    It means it cannot find the implementation of the server constructor. Have you written one which you do not show above?

    EDIT: Ok, so you’ve written one, but you’re not passing it to the compiler. You need to have proxy-server.cpp in your g++ line.

    EDIT 2: It is not enough to just compile the file containing main and include the header files. You need to provide all the cpp files to g++, or it will not be able to link your program.

    g++ proxy.cpp proxy-server.cpp proxy-conn.cpp -lboost_thread -lboost_filesystem -lboost_system
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.