Results 1 to 10 of 10

Thread: Exe not displaying images when compiled statically

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Exe not displaying images when compiled statically

    Quote Originally Posted by premroxx View Post
    I tried to do it dynamically.
    No, you didn't. The code posted suggests you are trying to use static plugins. The question is whether you have static plugins built in the first place.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Aug 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Exe not displaying images when compiled statically

    When building statically you may need to explicit load the .qrc resource file using the Q_INIT_RESOURCE macro:

    Qt Code:
    1. Q_INIT_RESOURCE(Backgrounds);
    To copy to clipboard, switch view to plain text mode 

    This should be done in the main.cpp file before the QApplication is constructed, if I'm not mistaken.

    By the way: This was my first post, so I really hope it helps
    Plan everything. Document everything. Version control everything. Test everything. Deny everything.

  3. #3
    Join Date
    Aug 2011
    Posts
    42
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: Exe not displaying images when compiled statically

    question is whether you have static plugins built in the first place
    This is what i have done so far.

    .pro
    CONFIG += static
    QTPLUGIN += qjpeg

    main.cpp
    #include <QtPlugin>
    Q_IMPORT_PLUGIN(qjpeg)

    I am getting an link(LINK2019) error. I also notice that the word 'QTPLUGIN' isn't showing up in a violet color like the other QT commands do? I have a imageformats folder(next to my .exe) with libqjpeg.a in it. What else am i doing wrong?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Exe not displaying images when compiled statically

    What is the error? My crystal ball is out of action...

  5. #5
    Join Date
    Aug 2011
    Posts
    42
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10

    Default Re: Exe not displaying images when compiled statically

    main.obj:-1: error: LNK2019: unresolved external symbol "class QObject * __cdecl qt_plugin_instance_qjpeg(void)" (?qt_plugin_instance_qjpeg@@YAPAVQObject@@XZ) referenced in function "public: __thiscall StaticqjpegPluginInstance::StaticqjpegPluginInstan ce(void)" (??0StaticqjpegPluginInstance@@QAE@XZ)

    debug\interface.exe:-1: error: LNK1120: 1 unresolved externals

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Exe not displaying images when compiled statically

    Forget the imageformats folder, it's only for dynamic plugins. The static plugins need to be available at compile time where the linker can find them.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Exe not displaying images when compiled statically

    Have you built Qt statically?
    You need to build your application with a static version of Qt, not just configure your project for a static build. If you have built both Qt and your application statically you should not need any Qt related dll's. In any event, when using qrc files you do not need to deploy the image files after compilation, they will be built inn to your executable.

    From the error message it looks like the linker can't find the static version of the qjpeg library, indicating either a faulty path or that you don't have the qjpeg static library. Static files will most likely be .a files if you are using the MinGW compiler, and .lib if you are using msvc.

    If all you want is for your images to show in the application, perhaps the dynamic approach is the better one, using qrc resource files. If you need to deploy your application as a part of your job, then static build may be the way to go, however you do need a commercial Qt license to deploy static Qt applications.
    Plan everything. Document everything. Version control everything. Test everything. Deny everything.

Similar Threads

  1. Replies: 0
    Last Post: 25th July 2011, 14:47
  2. Qt 4.7.0 statically compiled and Qt Creator
    By Suppaman in forum Installation and Deployment
    Replies: 6
    Last Post: 12th October 2010, 12:47
  3. Statically compiled Qt 4.1.4 and mySql
    By Djony in forum Installation and Deployment
    Replies: 1
    Last Post: 26th January 2007, 07:13
  4. Replies: 3
    Last Post: 26th July 2006, 13:23
  5. Qt is compiled statically, now what ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2006, 12:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.