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[])
{
Hello *hi = new Hello();
return app.exec();
}
#include <QCoreApplication>
#include "hello.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Hello *hi = new Hello();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
hello.h
#ifndef HELLO_H
#define HELLO_H
class Hello{
public:
Hello();
};
#endif // HELLO_H
#ifndef HELLO_H
#define HELLO_H
class Hello{
public:
Hello();
};
#endif // HELLO_H
To copy to clipboard, switch view to plain text mode
hello.cpp
#include <iostream>
class Hello{
public:
Hello(){
std::cout << "hello world" << std::endl;
}
};
#include <iostream>
class Hello{
public:
Hello(){
std::cout << "hello world" << std::endl;
}
};
To copy to clipboard, switch view to plain text mode
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
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
To copy to clipboard, switch view to plain text mode
It works fine without creating Hello object.
Bookmarks