supernatrium
6th December 2019, 16:16
Hello community,
I can't run my hello world program, I get LNK2019 error.
main.cpp
#include <QCoreApplication>
#include "hello.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Hello *hi = new Hello();
return app.exec();
}
hello.h
#ifndef HELLO_H
#define HELLO_H
class Hello{
public:
Hello();
};
#endif // HELLO_H
hello.cpp
#include <iostream>
class Hello{
public:
Hello(){
std::cout << "hello world" << std::endl;
}
};
myproject.pro
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
hello.cpp \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
hello.h
It works fine without creating Hello object.
I can't run my hello world program, I get LNK2019 error.
main.cpp
#include <QCoreApplication>
#include "hello.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Hello *hi = new Hello();
return app.exec();
}
hello.h
#ifndef HELLO_H
#define HELLO_H
class Hello{
public:
Hello();
};
#endif // HELLO_H
hello.cpp
#include <iostream>
class Hello{
public:
Hello(){
std::cout << "hello world" << std::endl;
}
};
myproject.pro
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
hello.cpp \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
hello.h
It works fine without creating Hello object.