0

I have a programme that I am writing in Qt Creator, and I am having some compilation issues. This is the error it gives:

Undefined symbols for architecture x86_64:
  "VehicleSizer::VehicleSizer(double, double, double, double, double, double, double, double, int)", referenced from:
      _main in MSSTO_SimulationTester.cpp.o

Reading other questions I thought it would be due to the mismatch between the declared function definitions in the header and the source file, or that the static variables must be initialised, but I don't think that is the case here. Here is my main file:

#include "Vehicle/vehicleSizer.h"
#include "Vehicle/vehicleSizerAbstract.h"


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>

int main( )
{
    {

        double totalBurnTimeUp = 100.;
        double massFlowUpper = 80.;
        double chamberPressure = 200000.;
        double exitDiameterUp = 1.2;
        double oxidizerOverFuel = 3.4;
        double upperStageDiameter = 6;
        double payloadMass = 1000;
        double __landingburn = 1.0;
        int __engines = 5;
      
      UpperStage = std::shared_ptr< VehicleSizerAbstract >(
                        new VehicleSizer(totalBurnTimeUp,
                                        __landingburn, 
                                        massFlowUpper, 
                                        chamberPressure, 
                                        exitDiameterUp, 
                                        oxidizerOverFuel, 
                                        upperStageDiameter, 
                                        payloadMass, 
                                        __engines));

      std::shared_ptr<VehicleSizerAbstract> Vehicle;

    }

    return 0;
}

Here is my abstract header file

#ifndef VEHICLESIZERABSTRACT_H
#define VEHICLESIZERABSTRACT_H

#define _USE_MATH_DEFINES

#include <iostream>
#include <fstream>
#include <cmath>

class VehicleSizerAbstract
{
public:

// some declared virtual functions that return doubles

virtual ~VehicleSizerAbstract(){}

protected:

// some declared variables

};

#endif // VEHICLESIZERABSTRACT_H

Here is my header file

#ifndef VEHICLESIZER_H
#define VEHICLESIZER_H

#define _USE_MATH_DEFINES

#include <iostream>
#include <fstream>
#include <cmath>

#include "vehicleSizerAbstract.h"

class VehicleSizer : public VehicleSizerAbstract
{
public:
    VehicleSizer(double m_ascentBurnTime, double m_landingBurnTime,
                 double m_massFlow, double m_chamberPressure,
                 double m_exhaustDiameter, double m_mixtureRatio,
                 double m_vehicleDiameter, double m_payloadMass,
                 int m_mainEngineAmount);

   // some declared functions that return doubles

private:
  // some declared void functions

};

#endif // VEHICLESIZER_H

Here is my cpp file:

#include "vehicleSizer.h"

VehicleSizer::VehicleSizer(double m_ascentBurnTime, double m_landingBurnTime,
                           double m_massFlow, double m_chamberPressure,
                           double m_exhaustDiameter, double m_mixtureRatio,
                           double m_vehicleDiameter, double m_payloadMass,
                           int m_mainEngineAmount)
{

// some functions
}

What am I missing? I have been looking through all of the similar questions and corresponding answers here but nothing seems to apply or to work. Thank you so much!

  • 1
    Maybe the cpp file is not being compiled. – drescherjm Dec 08 '20 at 16:15
  • You can use command line with several cpp files. like: `g++ vehicleSizer.cpp MSSTO_SimulationTester.cpp -o MSSTO_SimulationTester.out` or compile each cpp with -c flag then link all objects. or better: write a Makefile. – SHR Dec 08 '20 at 16:22
  • Maybe your cpp file is not listed in your SOURCES in your `.pro` file: [https://doc.qt.io/qt-5/qmake-project-files.html](https://doc.qt.io/qt-5/qmake-project-files.html) – drescherjm Dec 08 '20 at 16:41
  • Possible explanation here. https://stackoverflow.com/questions/18751868/undefined-symbols-for-architecture-x86-64-compiling-problems – CV_Ruddha Dec 08 '20 at 21:30

0 Answers0