0

For this question, i ahve basically four main files, let's call it:

Constant.hh 

Constant.cc (where a define the function)

Field.hh

Field.cc (where i call the function)

So basically, i have defined a function at the file "Constant.cc" and i am calling it to be used at Field.cc. But when i try to run it on terminal (using make), it returns this:

/usr/bin/ld: CMakeFiles/eRosita.dir/application/src/Field.cc.o: in function "FF::GetFieldValue(double const*, double*) const":
Field.cc:(.text+0xcc): undefined reference for "Constant(int, double)"
collect2: error: ld returned 1 exit status

And i am not sure why.

The content inside thes four files are:

Constant.hh

#ifndef Constant_h
#define Constant_h 1

double Constant(int f, double p);

#endif

Constant.cc

#include <iostream>

double Constant(int f, double p) {
if (f == 30){
return 3;}
else{
return 0;}
}

Field.hh

#ifndef Field_h
#define Field_h 1

class FF : public G4ElectroMagneticField {

    public:
        ~FF();
        virtual void  GetFieldValue(const G4double Point[4], G4double *Bfield ) const override;
        virtual G4bool DoesFieldChangeEnergy() const override;

};
#endif

Field.cc

#include "Constant.hh"

FF::~FF(){}

G4bool FF::DoesFieldChangeEnergy() const{
    return true;
}

void FF::GetFieldValue(const G4double Point[4], G4double field[6]) const
     
    double r = sqrt(x*x+y*y);

    double p = 2*pi*r/(400*0.025);
    int f = -20;
    
    double E = Constant(f,p);
  }

(OBS: the unecessary part of the code i have just deleted, so that the question get more summarized)

LSS
  • 127
  • 4

0 Answers0