Results 1 to 12 of 12

Thread: several misc questions - static build, jpeg plugin, etc - please help a newbie!

  1. #1
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default several misc questions - static build, jpeg plugin, etc - please help a newbie!

    first, sorry for my probably stupid questions (although this place is for newbies anyway).
    I am new to qt and c++.

    I use qt with mingw.
    I re-compileded qt libs statically for some reasons.
    (question 1:) now, isnt exists a way to compile some progs dynamically with this recompiled qt? I ran configure and make commands directly in my qt directory. now I cant make dynamically linked exe files even by specifying explicit dynamic linking options, but no errors and not even one warning are reported and static exes are generated instead of dynamic options.
    I first compiled for static libs by -static option to configure and then ran make (build process took several hours on my PIII system).
    That way qt libs were statically linked but I saw that mingw10.dll wasnt yet statically linked.
    So then again, according to articles I found on the web, I modified <qt dir>\mkspecs\win32-g++\qmake.conf and added -static to QMAKE_LFLAGS within it. And I ran 'configure -static -release -no-exceptions' and make (mingw32-make).
    This time my exe files became fully static, apparently. they can be ran alone, and of course, have a considerable size.
    I want to know some things. e.g. (question 2:) why I needed a recompilation on the whole qt for linking to mingw10.dll statically whereas mingw10.dll is from a seperate toolkit not belonging to qt; what is the job that qmake.conf and -static in QMAKE_LFLAGS do in these scenarios.
    (question 3:) what -no-exceptions does and why is needed and what limits it create for qt (or my c++ compilations in general?) apps?

    (for another question) I have a test prog:

    Qt Code:
    1. #include <QApplication>
    2. #include <QPixmap>
    3. #include <QPushButton>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. (new QPushButton())->show(); //only to let the user exit from app conveniently.
    10.  
    11. QPixmap img=QPixmap(500,500);
    12. img.save("result.png", "png");
    13.  
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    it is working.
    but indeed I wanted to save in jpg format:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPixmap>
    3. #include <QPushButton>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. (new QPushButton())->show(); //only to let the user exit from app conveniently.
    10.  
    11. QPixmap img=QPixmap(500,500);
    12. img.save("result.jpg", "jpg");
    13.  
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 
    this can be compiled with my static qt but the resulted jpg file is an empty file (0 bytes).
    now I add every other thing found regarding this to my project:

    Qt Code:
    1. #include <QApplication>
    2. #include <QPixmap>
    3. #include <QPushButton>
    4.  
    5. #include <QtPlugin>
    6. Q_IMPORT_PLUGIN(qjpeg)
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication app(argc, argv);
    11.  
    12. (new QPushButton())->show(); //only to let the user exit from app conveniently.
    13.  
    14. QPixmap img=QPixmap(500,500);
    15. img.save("result.jpg", "jpg");
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 
    and:
    Qt Code:
    1. QTPLUGIN += qjpeg
    To copy to clipboard, switch view to plain text mode 
    goes in the .pro file.

    But finally I get g++ compile error: release/main.o:main.cpp:(.text+0x119): undefined reference to `qt_plugin_instance_qjpeg()'
    I get this error both with static qt libs and dynamic qt libs (BTW I have two near versions of qt on my system installed separately).

    indeed first I wrote a jpg working prog (dynamically linked) that worked nice on my system; but when I ran it on another system that qt wasnt installed on, created jpg files became empty. I accompanied all the dlls that my prog demanded (qtgui, qtcore, mingw10.dll) and finally also qjpeg4.dll. but prog simply didnt work as expected, without giving any reason for that.
    so I decided to test a fully static prog and recompiled qt (...other parts of the story that you read from above).

    please help me!!

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

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    Quote Originally Posted by FS Lover View Post
    (question 1 now, isnt exists a way to compile some progs dynamically with this recompiled qt?
    No, you need to use the dynamically built one to build dynamic apps.

    I want to know some things. e.g. (question 2 why I needed a recompilation on the whole qt for linking to mingw10.dll statically whereas mingw10.dll is from a seperate toolkit not belonging to qt;
    You are not linking statically to mingw10.dll. You are linking to mingw10.a which is a static equivalent of the dll. And you needed to rebuild Qt for that because by default Qt is built dynamically against mingw10.dll so even if you linked your application statically against mingw10.a, Qt would still require the linker to link in the dll.

    what is the job that qmake.conf and -static in QMAKE_LFLAGS do in these scenarios.
    They instruct the compiler and linker how to build the application.

    (question 3 what -no-exceptions does
    It disables linking exception support into the application so that it is smaller.

    and why is needed
    It's not.

    and what limits it create for qt (or my c++ compilations in general?) apps?
    You can't use exceptions.


    But finally I get g++ compile error: release/main.o:main.cpp.text+0x119): undefined reference to `qt_plugin_instance_qjpeg()'
    Do you have the plugin compiled? What's inside your imageformats subdirectory of the plugins directory in Qt installation dir? If you don't have files with extension .a there then you don't have the static plugins.

    indeed first I wrote a jpg working prog (dynamically linked) that worked nice on my system; but when I ran it on another system that qt wasnt installed on, created jpg files became empty. I accompanied all the dlls that my prog demanded (qtgui, qtcore, mingw10.dll) and finally also qjpeg4.dll. but prog simply didnt work as expected, without giving any reason for that.
    How did it work and how did you expect it to?
    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.


  3. #3
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    What's inside your imageformats subdirectory of the plugins directory in Qt installation dir? If you don't have files with extension .a there then you don't have the static plugins.
    I have `qjpeg4.dll', `libqjpeg4.a' and `libqjpeg.a' there (in my statically compiled qt).
    and`qjpeg4.dll', `libqjpeg4.a' for my dynamic qt.
    of course, debug versions are also present in both.

    How did it work and how did you expect it to?
    I think I said already; it (even that simple prog that I inserted here) creates the target jpg file, but file is always empty (0 bytes).
    but on my own system it (my real prog or this simple test prog linked fully dynamically) is working and jpgs arent empty.
    from fully dynamically I mean compiled against dynamic qt libs and without static jpeg plugin.
    BTW I think I once read somewhere that there is such an issue on some systems and configurations with jpeg format (I dont know if its a known bug of qt or OS), but I didnt see a workaround. personally I tried static linking that fails in compiling the simplest jpg working progs with static jpeg plugin (so far I know, in static apps we cant use dynamic qt plugins).

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

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    Quote Originally Posted by FS Lover View Post
    I have `qjpeg4.dll', `libqjpeg4.a' and `libqjpeg.a' there (in my statically compiled qt).
    and`qjpeg4.dll', `libqjpeg4.a' for my dynamic qt.
    of course, debug versions are also present in both.
    You probably didn't include the static plugins properly into your qmake project file.

    I think I said already; it (even that simple prog that I inserted here) creates the target jpg file, but file is always empty (0 bytes).
    but on my own system it (my real prog or this simple test prog linked fully dynamically) is working and jpgs arent empty.
    http://www.qtcentre.org/forum/faq.ph...missing_images
    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.


  5. #5
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    I think the problem with jpeg is solved now for dynamic qgpeg plugin.
    I am sorry for wasting your time; apparently placing the qgpeg4.dll inside a directory called 'imageformats' in the application bundle was sufficient.

  6. #6
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    I found the real cause why jpeg plugin didn't load.
    I tell it for others here so that if someone had the same problem and found this topic can find the answer.
    my jpeg plugin's dll file had hidden file attribute (under MS Windows) and I found that qt doesn't load such hidden plugin dlls. this is not the case for other dlls such as qtgui4.dll, etc.

    indeed since I placed my program directly in the windows startup directory and needed to make hidden the accompanying files, I always made that dll hidden. but fortunately that was not necessary, because qjpeg4.dll should be placed inside another directory (imageformats) there and we can make hidden only that parent directory.

    note: hidden objects in the windows startup directory aren't automatically opened/executed on windows startup.

  7. #7
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default

    (question 3 what -no-exceptions does
    It disables linking exception support into the application so that it is smaller.
    and why is needed
    It's not.
    and what limits it create for qt (or my c++ compilations in general?) apps?
    You can't use exceptions.
    I don't know how much space does the exception support consume; can you tell me please?
    but I guess it can't be discarded so easily; at least not in all cases. somebody may need it and it become necessary. have qt replaced it with another substitute method?
    in wiki article there is no other option mentioned and all other sources in the web that I found are the same (apparently their main source was qtcentre's wiki article). if someone read them he will think that qt cant be compiled without -no-exceptions statically.
    so I suggest you strongly that you add extra explanations and mention another option (omitting -no-exceptions) in the wiki article: http://wiki.qtcentre.org/index.php?t..._Qt_on_Windows

    thanks.

    oh I have a question again.
    what does 'sub-src' say in the `mingw32-make sub-src' command?
    Last edited by wysota; 12th July 2009 at 17:30.

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

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    Quote Originally Posted by FS Lover View Post
    I don't know how much space does the exception support consume; can you tell me please?
    It probably depends on the architecture and compiler.

    but I guess it can't be discarded so easily; at least not in all cases.
    It's your decision to discard exception support or not.

    somebody may need it and it become necessary. have qt replaced it with another substitute method?
    If you replaced it with another solution, the resulting code wouldn't get any smaller, would it?

    in wiki article there is no other option mentioned and all other sources in the web that I found are the same (apparently their main source was qtcentre's wiki article). if someone read them he will think that qt cant be compiled without -no-exceptions statically.
    Hmm... Why? Sure it can, I did it many times myself.

    so I suggest you strongly that you add extra explanations and mention another option (omitting -no-exceptions) in the wiki article: http://wiki.qtcentre.org/index.php?t..._Qt_on_Windows
    What explanations exactly? By the way, you can edit the article yourself, you know...

    oh I have a question again.
    what does 'sub-src' say in the `mingw32-make sub-src' command?
    It means to build the src subproject only.
    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.


  9. #9
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    It means to build the src subproject only.
    what are the other parts that are (re)built without the sub-src option?
    can I use the sub-src option for re-compiling qt with phonon?

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

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    All the other subdirectories of the Qt source tree. As for the second question, look into the src directory and answer the question yourself.
    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.


  11. #11
    Join Date
    May 2009
    Posts
    147
    Thanks
    11
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    By the way, you can edit the article yourself, you know...
    unfortunately I have not any experience with wikies. I don't know the wiki syntax.

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

    Default Re: several misc questions - static build, jpeg plugin, etc - please help a newbie!

    You won't gain any if you don't try some day.
    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.


Similar Threads

  1. Extending a plugin in a static library
    By ultim8 in forum Qt Programming
    Replies: 5
    Last Post: 25th March 2010, 16:10

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.