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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:38:06+00:00 2026-05-17T23:38:06+00:00

I’m very confused by a compiler error. My code was thoroughly working 4-5 h

  • 0

I’m very confused by a compiler error. My code was thoroughly working 4-5 h ago; the only feasible checkpoint along the way hasn’t yielded any clues (i.e., I have not been able to get the error to disappear at one intermediate step). I don’t see how the compiler error could be related to any of the changes I have made.

Compiling with
g++ -O3 -o a.out -I /Applications/boost_1_42_0/ Host.cpp Simulation.cpp main.cpp Rdraws.cpp SimPars.cpp

the following error appears

Undefined symbols:
  "Simulation::runTestEpidSim()", referenced from:
      _main in ccmcSY5M.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I create and manipulate Simulation objects in main. My only changes to the code were (1) to create a new member function, Simulation::runTestEpidSim(), which is called in main, and (2) to write some new global input/output processing functions, which I’ve since unwrapped and inserted directly into main in order to debug what’s going on.

I have not changed any cpp files, includes, header files, libraries, or compiler commands.

I’m not a professional programmer. How would the pros go about debugging this kind of problem?

Not sure how best to cut and paste my code, but here’s an excerpt–

class Simulation
{
 public:
  Simulation( int trt, int sid, SimPars * spPtr  );
  ~Simulation();

  // MEMBER FUNCTION PROTOTYPES
  void runDemSim( void );
  void runEpidSim( void );
  double runTestEpidSim( void );
 ... 
 }

int main() {
 for ( int trt = 0; trt < NUM_TREATMENTS; trt++ ) {

   double treatment = TREATMENTS[ trt ];
   ....
   cout << "Treatment #" << trt + 1 << " of " << NUM_TREATMENTS << ":" << endl;
   int matchAttempts = 0;
   double prevError = 1.0 + PREV_ERROR_THOLD;
   double thisBeta = 0.0;
   while ( matchAttempts < MAX_MATCH_ATTEMPTS && prevError > PREV_ERROR_THOLD ) {
     cout << "  Attempt #" << matchAttempts + 1;
     SimPars thesePars;
     SimPars * spPtr = &thesePars;
     Simulation thisSim( trt, 1, spPtr );
     thisSim.runDemSim();
     prevError =  thisSim.runTestEpidSim() - TARGET_PREV;
     cout << ", error=" << prevError << endl;
     if ( prevError > PREV_ERROR_THOLD ) {
  ....

 return 0;
}

I had previously been executing runEpidSim() with no problem.

Update
I have the full code for the implementation of Simulation::runTestEpidSim()–I have no idea how best to present this!

double Simulation::runTestEpidSim( void ) {
  if ( allHosts.size() == 0 ) {  
    cerr << "No hosts remaining for epidemiological simulation. Cancelling." << endl;
    assert(false);
  }
  cout << "  Entering test simulation at t="  << demComplete << "." << endl;
  double percentDone = 0.0;

  // Initialize host population with infections
  demOutputStrobe = t;
  epidOutputStrobe = t;
  seedInfections();
  EventPQ::iterator eventIter = currentEvents.begin();
  double nextTimeStep = t + EPID_DELTA_T;
  double prevalences[ NUM_TEST_SAMPLES ]; // holds prevalences at strobing periods
  for ( int p = 0; p < NUM_TEST_SAMPLES; p++ ) {
    prevalences[ p ] = 0.0;
  }
  double prevYear = DEM_SIM_LENGTH + TEST_EPID_SIM_LENGTH - NUM_TEST_SAMPLES; // first simulation year to start sampling
  int prevSamples = 0;

  while ( t < TEST_EPID_SIM_LENGTH + demComplete )
    {

#ifdef DEBUG
      cout << "time step = " << t << " (" << allHosts.size() << " hosts; " << currentEvents.size() << " events queued)" << endl;
      assert( currentEvents.size()>0);
#endif

      // Calculate new infections for every host and add events to stack
#ifdef DEBUG
      cout << "Adding infections for this time step: " << endl;
#endif
      calcSI();
      eventIter = currentEvents.begin();

#ifdef DEBUG
      cout << "Executing events off stack (currentEvents.size()=" << currentEvents.size() << "): " << endl;
#endif      

      while ( ( *eventIter ).time < nextTimeStep ) { 

    while ( demOutputStrobe < t ) { 
      writeDemOutput();
      demOutputStrobe += STROBE_DEM;
    }
    while ( epidOutputStrobe < t ) { 
      writeEpidOutput();
      epidOutputStrobe += STROBE_EPID;
    }
    if ( prevYear < t ) {
      prevalences[ prevSample ] = calcPrev();
      cout << "\tOutputting prevalence sample #" << prevSamples+1 << "; prevalence under 5 is " << prevalences[ prevSample ] << endl;
      prevSample++;
    }
        while ( percentDone/100.0 < ( t - demComplete )/EPID_SIM_LENGTH  ) {
      cout << "\t" << percentDone << "% of this test component complete." << endl;
      percentDone += PROGRESS_INTERVAL; 
      } 

    // Execute events off stack
    Event thisEvent = *eventIter;
#ifdef DEBUG
    assert( thisEvent.time >= t );
    if ( thisEvent.time < t ) {
      cout << "Trying to execute event scheduled for time " << thisEvent.time << ", though sim time is " << t << endl;
      assert( thisEvent.time >= t );
    }
#endif
    t = thisEvent.time;


#ifdef DEBUG
    cout << "\tt=" << t << endl;
    //  cout << "\tAbout to execute event ID " << (*eventIter).eventID << " at time " << (*eventIter).time << " for host ID " << (*eventIter).hostID << endl;
    cout << "\tAbout to execute event ID " << thisEvent.eventID << " at time " << thisEvent.time << " for host ID " << thisEvent.hostID << endl;
#endif
    executeEvent( thisEvent );
    eventCtr++;
    currentEvents.erase( eventIter ); // Check that if event added to top of currentEvents, will not invalidate itr
    eventIter = currentEvents.begin();

#ifdef DEBUG
    cout << "\tcurrentEvents.size() after pop is " << currentEvents.size() << endl;
#endif

      }

      t = nextTimeStep;
      nextTimeStep += EPID_DELTA_T;
    }

  double meanPrev = 0.0;
  double sumPrev = 0.0;
  int totSamples = 0;
  for (  int p = 0; p < NUM_TEST_SAMPLES; p++ ) {
    if ( prevalences[ p ] > 0 ) { // in cae
      sumPrev += prevalences[ p ];
      totSamples++;
    }
  }
  cout << "Counted " << totSamples << " total prevalence samples." << endl;
  meanPrev = sumPrev/(double)totSamples;
  return( meanPrev );
}
  • 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-17T23:38:06+00:00Added an answer on May 17, 2026 at 11:38 pm

    How would the pros go about debugging
    this kind of problem?

    You should start with the error message:

    Undefined symbols:"Simulation::runTestEpidSim()"
    

    You’ve added a prototype for runTestEpidSim, but you haven’t shown the definition of this function (presumably it should be in Simulation.cpp)

    Here’s what I’d look for, to start…

    • Have you defined it at all?
    • Have you defined it as a member of class Simulation?
    • Have you defined it with exactly the same parameters?
    • Have you defined it with exactly the same return type?
    • Is the definition accidentally commented or #ifdef’d out?

    Update
    Thanks for posting the definition. What you’ve posted looks fine, and passes the first four tests above – but you can see how a mismatched #ifdef DEBUG could mess things up for you…

    In addition…

    • Have you actually compiled and linked with the file containing the definition?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.