I have a class with a default constructor, and a constructor that takes 8 arguments.
from another class i am trying to call the constructor and pass 8 parameters however when i try to do this i am getting a LNK2019 Error
.
The thing thats confusing me though is if i call the default constructor nothing the program compiles and runs fine... everything has the correct includes and must be working because i can call the default constructor, i am using QStrings as some of the arguments but QString is included so it cant be that... any other reason anyone knows of why i would geta LNK2019 error
for a constructor taking arguments and not when its the default one??
Car.h
#include <QString>
class car
{
public:
car();
car(int car_id, QString something, QString something_else, QString something3, int an_int, int another_int, int another_int_i, QString something4);
};
car.cpp
car::car()
{
}
car::car(int car_id, QString something, QString something_else, QString something3, int an_int, int another_int, int another_int_i, QString something4)
{
}
obviously i have just removed context and values etc but makes no difference on structure
DatabaseController.cpp
#include "DatabaseController.h"
#include "car.h"
void DatabaseController::DoSomething()
{
car *pcar = new car(0, "", "", "", 0, 0, 0, "");
}
interface.cpp
#include "DatabaseController.h"
void interface::on_btn_clicked()
{
DatabaseController DC;
DC.DoSomething();
}
FULL ERROR:
DatabaseController.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall car::car(int,class QString,class QString,class QString,int,int,int,class QString)" (??0car@@QAE@HVQString@@00HHH0@Z) referenced in function "public: void __thiscall DatabaseController::getAll(class QString)" (?getAll@DatabaseController@@QAEXVQString@@@Z)
I know this is a really late response but I struggled for a long time with the same issue.
QT doesn't always parse the c++ files correctly when doing a clean->rebuild. Luckily to force it to do so just manually delete the build files and it will run from scratch.
It worked for me and I hope it helps a few people!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With