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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:13:47+00:00 2026-06-01T17:13:47+00:00

I am getting a linking error (undefined reference) when I try to link my

  • 0

I am getting a linking error (undefined reference) when I try to link my code and I can’t figure out why.

I am linking using the following command:
mpic++ -Wl,-V main.o Particle.o Particle_forces.o User_input.o output.o time_step_Gear_Verlet.o Verlet_variables.o -o DEM.exe -Lboost_mpi.a -Lboost_serialization.a

The error I get tells me the “step(…) function in main.cpp is undefined.

So…the code for main() looks something like this(I left off the includes, but it does include the header with the step() function, which is obvious since I had no compile errors):

int main() 
{

//do some stuff


for(int i=0;i<input_data.nstep();i++)
{
    //call step() to do all calculations necessary for a particular timestep
    step(particles, safe_particles, particle_properties, particle_forces, input_data, verlet_list, verlet_celllist, coll_eros_track, tan_contact_histories, collision_number_part);

    //do some more stuff
}


return 0;
}

And the step function can be found in time_step_Gear_Verlet.cpp:

void step(std::vector<Particle> & particles, std::vector<Particle> & safe_particles, std::vector<Particle_props> & particle_properties, std::vector<Particle_forces> & particle_forces, User_input& input_data, std::vector<std::set<int> > & verlet_list, vector<vector<vector<vector<int> > > > verlet_celllist, data_tracking & coll_eros_track, vector<map<int,Vector> > & tan_contact_histories, vector<int> & collision_number_part)
{
    //define booleans used for checking what to do
    //newverlet states whether the verlet lists are currently new and ok will be the output to make_verlet
    bool ok=true, newverlet=false;

    if(input_data.collisions_on())
    {
        //uses verlet_needs_update() to see if the verlet lists need to be updated
        if(verlet_needs_update(particles, safe_particles, input_data))
        {
            //if the lists need to be updated then a call to make_verlet is made to make new lists and output is stored in "ok"
            ok=make_verlet(particles, particle_properties, input_data, verlet_celllist, verlet_list);

            //since new lists have been made, newverlet becomes true
            newverlet=true;
        }

        //if something went wrong when the new lists were made, then a restoration has to be made
        if(!ok)
        {
            cout<<"verlet list construction failed due to particles already touching. Try changing the verlet distance"<<endl;
            exit(1);
        }

        //if the lists are new and make_verlet worked fine, then store current particle values
        if (newverlet && ok)
        {
            //store current particle and time values
            safe_particles=particles;
        }
    }
    //call integrate() to integrate the equations of motion
    integrate(particles, particle_properties, particle_forces, input_data, verlet_list, coll_eros_track, tan_contact_histories, collision_number_part);
}

The header definition:

#ifndef time_step_Gear_h
#define time_step_Gear_h

#include <vector>
#include <map>
#include <set>

#include "Particle.h"
#include "Particle_props.h"
#include "Particle_forces.h"
#include "User_input.h"
#include "data_tracking.h"

void step(std::vector<Particle> &, std::vector<Particle> &, std::vector<Particle_props> &, std::vector<Particle_forces> &, User_input&, std::vector<std::set<int> > &, std::vector<std::vector<std::vector<std::vector<int> > > > &, data_tracking &, std::vector<std::map<int,Vector> > &, std::vector<int> &);
void make_forces(std::vector<Particle> &, std::vector<Particle_props> &, std::vector<Particle_forces> &, User_input&, std::vector<std::set<int> > &, data_tracking &, std::vector<std::map<int,Vector> > &, std::vector<int> &);
void integrate(std::vector<Particle> &, std::vector<Particle_props> &, std::vector<Particle_forces> &, User_input&, std::vector<std::set<int> > &, data_tracking &, std::vector<std::map<int,Vector> > &, std::vector<int> &);
void init_algorithm(std::vector<Particle> &, vector<Particle> & safe_particles, std::vector<Particle_props> &, User_input&, std::vector<std::vector<std::vector<std::vector<int> > > > &, std::vector<std::set<int> > &);


#endif

I am clearly linking the files together (and the order has no effect). I am not having this issue with any other function that is called from main.cpp and defined within another .cpp file (and commenting out the call to step() causes no errors at all). Any ideas what might be causing this issue?

  • 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-01T17:13:48+00:00Added an answer on June 1, 2026 at 5:13 pm

    looks like you’re missing an & in your definition. Check verlet_celllist

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

Sidebar

Related Questions

Here is the code, why am I getting an undefined reference while linking? g++
I'm using visual studio 2003 and I'm getting the following linking error in my
I am getting the following linking error : libOpenSSL.lib(cryptlib.obj) : error LNK2001: unresolved external
Getting the above error in following code. How to rectify it. Thanks. Please look
Hi I am getting the following Linking error while compiling ConvolutionFFT2D from CUDA src
I am getting this error after adding the libxml2.2.dylib file Linking /Users/Biranchi/Desktop/Funmovies TabBarController/build/Debug-iphonesimulator/funmovies.app/funmovies (1
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
I'm getting a totally bizzare error trying to compile a C program using GCC.
So, I'm a bit confused on this error that I'm getting while compiling/linking a
I'm using libcurl and am getting the following sort of linker errors in VC++

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.