Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt linker error LNK2019 on qInitResources() - RCC

I want to compile a project with Qt in Visual Studio 2010. I have built all the prerequisite libraries and linked them in project properties.

I have also made the .cpp file from the project.qrc file (rcc) with the command below:

rcc project.qrc -name project -o qrc_project.cpp

Followed the instructions from http://www.qtcentre.org/archive/index.php/t-3425.html .

The project.coo file is produced with the following lines:

    int QT_MANGLE_NAMESPACE(qInitResources_project)()
    {
        QT_PREPEND_NAMESPACE(qRegisterResourceData)
            (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
        return 1;
    }
    
    Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_project))

I have also included the .cpp file in the project. Although, I get the error below:

> Error 2611    error LNK2019: unresolved external symbol "int __cdecl
> qInitResources_project(void)" (?qInitResources_project@@YAHXZ)
> referenced in function main   D:\usr\Windows\main.obj project

Have I done something wrong with the rcc? Could anyone please help?

like image 838
MTs Avatar asked Sep 12 '25 06:09

MTs


1 Answers

I solved my problem by producing a .rcc file and a .cpp file, both with the name of the project and not with the "qrc_" at the beginning of it. I have also linked both files on my project.

It seems that the compiler could not find the proper file, this is why i had the linking error.

The commands I used in order to produce the files mentioned above are:

  1. rcc -binary <path_to_qrc_file>.qrc -o <path_and_filename>.rcc

  2. rcc <path_to_qrc_file>.qrc -name <project_name> -o <path_and_filename>.cpp

like image 107
MTs Avatar answered Sep 13 '25 20:09

MTs