Qt Quick을 사용하여 파일 작업을 위한 작은 응용 프로그램을 만듭니다. 내 build/
폴더 에서 한 순간까지 모든 것이 작동했습니다.
rm -rf *
cmake ..
make
그런 다음이 오류로 중지되었습니다 (목록이 거대합니다. 중요하지 않은 부분은 제외했습니다).
[100%] Linking CXX executable uint32_sort_gui
In function `LibController::~LibController()':
lib_controller.cpp:(.text+0x10): undefined reference to `vtable for LibController'
main.cpp.o: In function `int qmlRegisterType<LibController>(char const*, int, int, char const*)':
...
여기 내입니다 .hpp
및 .cpp
클래스의 파일 :
lib_controller.hpp
#include <QObject>
#include <QString>
class LibController : public QObject{
Q_OBJECT
Q_PROPERTY(decltype(getProgress) progress READ getProgress NOTIFY ProgressChanged)
public:
explicit LibController(QObject *parent = 0);
~LibController();
double getProgress();
Q_INVOKABLE
void addFile(QString from_name, QString to_name);
Q_INVOKABLE
void sortFile();
signals:
void ProgressChanged();
private:
double current_progress;
FileManager* file_manager;
};
lib_controller.cpp
#include "lib_controller.hpp"
LibController::~LibController(){
delete file_manager;
}
double LibController::getProgress(){...}
void LibController::addFile(QString from_name, QString to_name){...}
void LibController::sortFile(){...}
메인.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlComponent>
#include "lib_controller.hpp"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// Registration of custom type
qmlRegisterType<LibController>("com.sort.controller", 0, 1, "LibController");
...
return app.exec();
}
그리고 내 CMakeLists.txt 구성.
이 문제에 대한 다른 질문을 읽었지만 청소 및 재구축이 도움이 되지 않았습니다(심지어 실수로 전체 프로젝트 폴더를 삭제했습니다).
문제가 지속되고 해결 방법을 이해하지 못합니다 ...
UPD:
다음은 전체 오류 메시지입니다.
UPD2:
LibController
프로젝트에서 제외 하고 다시 컴파일하면 오류가 사라지지만 창이 표시되지 않습니다. 터미널에서 실행 중인 것을 볼 수 있지만 GUI가 표시되지 않습니다.
문제는 에 있는 것이 LibController
아니라 다른 곳에 있는 것 같습니다.
cmake가 AUTOMOC를 실행할 수 있도록 소스 파일 목록에 헤더를 추가해야 합니다.
이 질문은 이미 여기에서 질문하고 답변했습니다. 헤더 파일의 위치를 변경하면 CMake로 컴파일할 때 누락된 vtable 오류가 발생합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다