Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QScriptEngine: undefined reference to `recd::qInitResources_app()'
Forum Updated to NodeBB v4.3 + New Features

QScriptEngine: undefined reference to `recd::qInitResources_app()'

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 912 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrbitmap
    wrote on last edited by
    #1

    Hello,
    I'm following the example for the qScriptEngine from here:
    https://doc.qt.io/qt-5/qtscript-script-helloscript-example.html
    I've setup my project as follows: In the subdirs project my .pro file is that way:

    # commnon stuff for everyone
    include($$top_srcdir/recd2.pri)
    
    CONFIG += c++11
    
    TARGET = recd2
    CONFIG += console
    CONFIG -= app_bundle
    
    RESOURCES += \
        hello_app.qrc
    
    TEMPLATE = app
    
    SOURCES += main.cpp \
        sapplication.cpp \
    
    HEADERS += \
        sapplication.h \
    
    # redefine a Makefile INSTALL_PROGRAM variable. We want to instal wit SUID bit
    QMAKE_INSTALL_PROGRAM = install -m 4755 -p
    
    target.path = /usr/bin
    INSTALLS += target
    
    debug
    {
        message("Debug mode")
        QMAKE_CXXFLAGS += -DRECD_DEBUG
    }
    
    PRE_TARGETDEPS += \
        $$top_builddir/utils/libutils.a
    
    

    In my .qrc file I've declared the script that way:

    <RCC>
        <qresource prefix="/">
            <file>hello_app.js</file>
        </qresource>
    </RCC>
    
    

    The hello_app.js is in the same folder as .pro and .qrc files. So when I try to build the program I receive the message: : error: undefined reference to recd::qInitResources_hello_app(). From file with that content:

    SApplication::SApplication(int &argc, char **argv)
        : QCoreApplication(argc, argv),
          m_setup(false)
    {
        // proxy them to the plugins if needed
        s_argc = argc;
        s_argv = argv;
        if (temp_test_enable) {
            Q_INIT_RESOURCE(hello_app); // THE ERROR 
    
            QScriptEngine engine;
            QTranslator translator;
            translator.load("app_la");
            installTranslator(&translator);
            QString fname(":/scripts/app.js");
            QFile file(fname);
            file.open(QIODevice::ReadOnly);
            QTextStream strm(&file);
            QString content = strm.readAll();
            file.close();
            QScriptValue evVal = engine.evaluate(content, fname);
            if (evVal.isError()) {
                exit(-1);
            }
        }
    ....
    }
    

    So what am I doing wrong?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrbitmap
      wrote on last edited by
      #2

      I've solved the problem: I've placed Q_INIT_RESOURCE in main and it compiled successfully.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved