0

the class constructor declaration in .hpp:

physicsBody(float m, std::vector<float> verts, std::vector<float> initPos, std::vector<float> initVelo);

the class variable declaration in .hpp:

ParticleSystem body;
float mass;
std::vector<float> vertices;
std::vector<float> initialPos;
std::vector<float> initialVelo;

the class constructor implementation in .cpp:

physicsBody::physicsBody(float m,
                         std::vector<float> verts,
                         std::vector<float> initPos,
                         std::vector<float> initVelo):
mass{m}, vertices{verts}, initialPos{initPos}, initialVelo{initVelo}
{    
    build_body();
    
    // Gravity is enabled as defalut
    for (auto& particle : body.pSystem)     particle.force[1] = -GRAVITY * particle.m;
} 

In Main():

    float mass {2.0}; // in kg
    std::vector<float> initialPos = {0.0, 0.0, 0.0};
    std::vector<float> initialVel = {0.0, 0.0, 0.0};
    std::vector<float> verts = ball.vertices;
    physicsBody myball(mass, verts, initialPos, initialVel);

When I build, it gives me this error:

"physicsBody::physicsBody(float, std::__1::vector<float, std::__1::allocator >, std::__1::vector<float, std::__1::allocator >, std::__1::vector<float, std::__1::allocator >)", referenced from: _main in main.o

After a few searches, the error can come from the class instantiation does not match the definition, or declaration does not match implementation. I have been scratching my head in the past a few hours. Cannot fix it! My head must have been stuck in the somewhere! Could someone please help! Thanks in advance!

Marvin
  • 25
  • 4
  • *When I build* How do you build? – 273K Mar 03 '22 at 15:36
  • what do you mean? command + B in xcode – Marvin Mar 03 '22 at 15:38
  • TLDR of the duplicate, you need to compile and link all your files together. Looks like you are only compiling main.cpp, and not your other file. – ChrisMM Mar 03 '22 at 15:39
  • Xcode generates a detailed build log when it builds your project. It might be worth taking a look at that to see if it is compiling (and linking) all the files you expect it to. – Paul Sanders Mar 03 '22 at 16:27

0 Answers0