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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:00:51+00:00 2026-05-25T03:00:51+00:00

I have run into a peculiar error in a C++ project at work. I

  • 0

I have run into a peculiar error in a C++ project at work.

I have found a fix, but I am now really satisfied, as I would like to understand what actually causes the error.

When building this snippet of code:

#include <iostream>
#include "snmp/snmp/SW_SNMP_Values.hpp"
#include "snmp/agent/SW_Agent.hpp"
#include "snmp/agent/SW_Agent_PP.hpp"

int main()
{
    //SW_Agent_PP agent;

    return 0;
}

Notice that SW_Agent_PP is COMMENTED OUT!! When building this, I get a ton of undefined reference errors, for classes that are in use by the SW_Agent_PP object.

The FIX is to ACTUALLY CREATE THE OBJECT! so if I do this:

#include <iostream>
#include "snmp/snmp/SW_SNMP_Values.hpp"
#include "snmp/agent/SW_Agent.hpp"
#include "snmp/agent/SW_Agent_PP.hpp"

int main()
{
    SW_Agent_PP agent;

    return 0;
}

everything works fine and dandy.

How can I get linker errors for NOT using something? I would like to hear if anyone have run into similar experiences before, and if they found what caused it.

I am sorry, but I cannot release more code as it is company property.
Many thanks in advance!

  • 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-25T03:00:52+00:00Added an answer on May 25, 2026 at 3:00 am

    Linkers are complicated and this behaviour is by no means unusual. Here’s one possible explanation:

    1. You are linking with a static library libfoo.a.
    2. libfoo.a contains foo.o that contains SW_Agent_PP::SW_Agent_PP() and a bunch of other functions.
    3. Another library libbar.a, listed after libfoo.a in the link line, uses a bunch of other functions from libfoo.a.

    The linker processes static libraries in order and never goes back. Therefore the references in libbar.a can be only satisfied if corresponding object was pulled from libfoo.a by main().

    The solution is to reorder the libraries in the link line.

    There are other possible explanations. It’s hard to tell without seeing actual code.

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

Sidebar

Related Questions

I have run into this problem again and now really need to know how
I have run into this problem a lot in the past, but never really
I have run into this problem before but never quite solved it. I have
Possible Duplicate: Conditional operator cannot cast implicitly? I have run into a peculiar situation
I have run into another problem with my current project. I have a form
I have run into the following error trying to create a user in django:
I have run into a really odd bug with FF3.5.9 (and potentially lower) where
Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work
I have run into a problem using PDO because an error was not caught.
I have run into a problem and would appreciate help devising a creative, and

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.