Results 1 to 9 of 9

Thread: compiling for Windows

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    74

    Question compiling for Windows

    I have a console application that produces a text file and a jpg image. It works fine under Linux but under Windows the jpg file is empty (0 kb). I'm using Qt4.4.3. My Linux Qt is dynamic, my windows Qt is static (built statically).

    This is my *.pro file.
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. # Input
    7. HEADERS += functions.cpp
    8. SOURCES += functions.cpp main.cpp
    To copy to clipboard, switch view to plain text mode 

    Trying to make the program to work under Windows I changed my *.pro file to this:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. # Input
    7. HEADERS += functions.cpp
    8. SOURCES += functions.cpp main.cpp
    9. CONFIG += console
    10. CONFIG += staticlib
    11. QTPLUGIN += qjpeg \
    12. qgif \
    13. qtiff \
    14. qmng
    To copy to clipboard, switch view to plain text mode 

    ..but still the program cannot produce a jpg file under Windows.

    Could anyone suggest what else I could try? I would really appreciate any help.

    My Makefile is this, in case that helps:
    Qt Code:
    1. first: all
    2. install: debug-install release-install
    3. uninstall: debug-uninstall release-uninstall
    4. MAKEFILE = Makefile
    5. QMAKE = c:\Qt\4.4.3\bin\qmake.exe
    6. DEL_FILE = del
    7. CHK_DIR_EXISTS= if not exist
    8. MKDIR = mkdir
    9. COPY = copy /y
    10. COPY_FILE = $(COPY)
    11. COPY_DIR = xcopy /s /q /y /i
    12. INSTALL_FILE = $(COPY_FILE)
    13. INSTALL_PROGRAM = $(COPY_FILE)
    14. INSTALL_DIR = $(COPY_DIR)
    15. DEL_FILE = del
    16. SYMLINK =
    17. DEL_DIR = rmdir
    18. MOVE = move
    19. CHK_DIR_EXISTS= if not exist
    20. MKDIR = mkdir
    21. SUBTARGETS = \
    22. debug \
    23. release
    24.  
    25. debug: $(MAKEFILE).Debug FORCE
    26. $(MAKE) -f $(MAKEFILE).Debug
    27. debug-make_default: $(MAKEFILE).Debug FORCE
    28. $(MAKE) -f $(MAKEFILE).Debug
    29. debug-make_first: $(MAKEFILE).Debug FORCE
    30. $(MAKE) -f $(MAKEFILE).Debug first
    31. debug-all: $(MAKEFILE).Debug FORCE
    32. $(MAKE) -f $(MAKEFILE).Debug all
    33. debug-clean: $(MAKEFILE).Debug FORCE
    34. $(MAKE) -f $(MAKEFILE).Debug clean
    35. debug-distclean: $(MAKEFILE).Debug FORCE
    36. $(MAKE) -f $(MAKEFILE).Debug distclean
    37. debug-install: $(MAKEFILE).Debug FORCE
    38. $(MAKE) -f $(MAKEFILE).Debug install
    39. debug-uninstall: $(MAKEFILE).Debug FORCE
    40. $(MAKE) -f $(MAKEFILE).Debug uninstall
    41. release: $(MAKEFILE).Release FORCE
    42. $(MAKE) -f $(MAKEFILE).Release
    43. release-make_default: $(MAKEFILE).Release FORCE
    44. $(MAKE) -f $(MAKEFILE).Release
    45. release-make_first: $(MAKEFILE).Release FORCE
    46. $(MAKE) -f $(MAKEFILE).Release first
    47. release-all: $(MAKEFILE).Release FORCE
    48. $(MAKE) -f $(MAKEFILE).Release all
    49. release-clean: $(MAKEFILE).Release FORCE
    50. $(MAKE) -f $(MAKEFILE).Release clean
    51. release-distclean: $(MAKEFILE).Release FORCE
    52. $(MAKE) -f $(MAKEFILE).Release distclean
    53. release-install: $(MAKEFILE).Release FORCE
    54. $(MAKE) -f $(MAKEFILE).Release install
    55. release-uninstall: $(MAKEFILE).Release FORCE
    56. $(MAKE) -f $(MAKEFILE).Release uninstall
    57.  
    58. Makefile: bitwalk.pro ../../.qmake.cache c:/Qt/4.4.3/mkspecs/win32-g++/qmake.conf c:/Qt/4.4.3/mkspecs/features/exclusive_builds.prf \
    59. c:/Qt/4.4.3/mkspecs/features/default_pre.prf \
    60. c:/Qt/4.4.3/mkspecs/features/win32/default_pre.prf \
    61. ../../.qmake.cache \
    62. ../../mkspecs/qconfig.pri \
    63. c:/Qt/4.4.3/mkspecs/features/qt_functions.prf \
    64. c:/Qt/4.4.3/mkspecs/features/qt_config.prf \
    65. c:/Qt/4.4.3/mkspecs/features/debug.prf \
    66. c:/Qt/4.4.3/mkspecs/features/debug_and_release.prf \
    67. c:/Qt/4.4.3/mkspecs/features/default_post.prf \
    68. c:/Qt/4.4.3/mkspecs/features/staticlib.prf \
    69. c:/Qt/4.4.3/mkspecs/features/static.prf \
    70. c:/Qt/4.4.3/mkspecs/features/win32/console.prf \
    71. c:/Qt/4.4.3/mkspecs/features/win32/rtti.prf \
    72. c:/Qt/4.4.3/mkspecs/features/win32/stl.prf \
    73. c:/Qt/4.4.3/mkspecs/features/warn_on.prf \
    74. c:/Qt/4.4.3/mkspecs/features/qt.prf \
    75. c:/Qt/4.4.3/mkspecs/features/win32/thread.prf \
    76. c:/Qt/4.4.3/mkspecs/features/moc.prf \
    77. c:/Qt/4.4.3/mkspecs/features/win32/exceptions_off.prf \
    78. c:/Qt/4.4.3/mkspecs/features/resources.prf \
    79. c:/Qt/4.4.3/mkspecs/features/uic.prf \
    80. c:/Qt/4.4.3/mkspecs/features/yacc.prf \
    81. c:/Qt/4.4.3/mkspecs/features/lex.prf \
    82. c:/Qt/static/lib/QtGuid.prl \
    83. c:/Qt/static/lib/QtCored.prl
    84. $(QMAKE) -win32 -o Makefile bitwalk.pro
    85. c:\Qt\4.4.3\mkspecs\features\exclusive_builds.prf:
    86. c:\Qt\4.4.3\mkspecs\features\default_pre.prf:
    87. c:\Qt\4.4.3\mkspecs\features\win32\default_pre.prf:
    88. ..\..\.qmake.cache:
    89. ..\..\mkspecs\qconfig.pri:
    90. c:\Qt\4.4.3\mkspecs\features\qt_functions.prf:
    91. c:\Qt\4.4.3\mkspecs\features\qt_config.prf:
    92. c:\Qt\4.4.3\mkspecs\features\debug.prf:
    93. c:\Qt\4.4.3\mkspecs\features\debug_and_release.prf:
    94. c:\Qt\4.4.3\mkspecs\features\default_post.prf:
    95. c:\Qt\4.4.3\mkspecs\features\staticlib.prf:
    96. c:\Qt\4.4.3\mkspecs\features\static.prf:
    97. c:\Qt\4.4.3\mkspecs\features\win32\console.prf:
    98. c:\Qt\4.4.3\mkspecs\features\win32\rtti.prf:
    99. c:\Qt\4.4.3\mkspecs\features\win32\stl.prf:
    100. c:\Qt\4.4.3\mkspecs\features\warn_on.prf:
    101. c:\Qt\4.4.3\mkspecs\features\qt.prf:
    102. c:\Qt\4.4.3\mkspecs\features\win32\thread.prf:
    103. c:\Qt\4.4.3\mkspecs\features\moc.prf:
    104. c:\Qt\4.4.3\mkspecs\features\win32\exceptions_off.prf:
    105. c:\Qt\4.4.3\mkspecs\features\resources.prf:
    106. c:\Qt\4.4.3\mkspecs\features\uic.prf:
    107. c:\Qt\4.4.3\mkspecs\features\yacc.prf:
    108. c:\Qt\4.4.3\mkspecs\features\lex.prf:
    109. c:\Qt\static\lib\QtGuid.prl:
    110. c:\Qt\static\lib\QtCored.prl:
    111. qmake: qmake_all FORCE
    112. @$(QMAKE) -win32 -o Makefile bitwalk.pro
    113.  
    114. qmake_all: FORCE
    115.  
    116. make_default: debug-make_default release-make_default FORCE
    117. make_first: debug-make_first release-make_first FORCE
    118. all: debug-all release-all FORCE
    119. clean: debug-clean release-clean FORCE
    120. distclean: debug-distclean release-distclean FORCE
    121. -$(DEL_FILE) Makefile
    122.  
    123. debug-mocclean: $(MAKEFILE).Debug
    124. $(MAKE) -f $(MAKEFILE).Debug mocclean
    125. release-mocclean: $(MAKEFILE).Release
    126. $(MAKE) -f $(MAKEFILE).Release mocclean
    127. mocclean: debug-mocclean release-mocclean
    128.  
    129. debug-mocables: $(MAKEFILE).Debug
    130. $(MAKE) -f $(MAKEFILE).Debug mocables
    131. release-mocables: $(MAKEFILE).Release
    132. $(MAKE) -f $(MAKEFILE).Release mocables
    133. mocables: debug-mocables release-mocables
    134. FORCE:
    135.  
    136. $(MAKEFILE).Debug: Makefile
    137. $(MAKEFILE).Release: Makefile
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: compiling for Windows

    My guess is you don't have an imageformat plugin for JPEG in your static Windows build.
    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
    Aug 2009
    Posts
    122
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    74

    Default Re: compiling for Windows

    Hi,

    Actually I do have this imageformat plugin. I've used the same static build numerous times with GUI and it can create static applications that can great jpg just fine. The exe file of my simple script is 7 MB which also shows that the plugins were incorporated.

    Some parts of my main.cpp look like this:
    Qt Code:
    1. #include <QApplication>
    2. #include <QCoreApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6.  
    7.  
    8. //QCoreApplication application(argc, argv);
    9. QApplication application(argc, argv);
    10.  
    11. //other functions
    12. }
    To copy to clipboard, switch view to plain text mode 

    I'm actually not sure if I should use QApplication or QCoreApplication for this console program? Could this issue have something to do with not being able to create jpg?

    Any other suggestions are most welcome as I really need to get this to work. I reduced my script down to just a few lines that create an empty image. It still works under Linux but not under Windows. Does anyone have a very simple example code that is known to work (makes a jpg) with static compilation under Windows? Especially the pro file. Thanks.
    Last edited by timmu; 24th October 2012 at 06:14.

  4. #4
    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
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: compiling for Windows

    Does it work if you create a png file instead of jpeg?
    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. The following user says thank you to wysota for this useful post:

    timmu (24th October 2012)

  6. #5
    Join Date
    Aug 2009
    Posts
    122
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    74

    Default Re: compiling for Windows

    Thanks, Wysota for an interesting hint.

    Indeed it works will with png. It has no problem making png image.
    It can also make BMP image just fine and all this regardless whether I use
    QApplication or QCoreApplication in my main.cpp.

    What does this mean?
    Last edited by timmu; 24th October 2012 at 10:07.

  7. #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
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: compiling for Windows

    It means you don't have a working JPEG static plugin. See what QImageWriter::supportedImageFormats() returns.
    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.


  8. The following user says thank you to wysota for this useful post:

    timmu (24th October 2012)

  9. #7
    Join Date
    Aug 2009
    Posts
    122
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    74

    Default Re: compiling for Windows

    Thanks again.
    I think I could use some help with running this QImageWriter::supportedImageFormats() test. Would you be able to help with more details as to what exactly I should put in my code? Thanks!

    In my /plugins/imageformats folder I have libqjpeg.a and libqjpegd.a. Does that mean that I have the plugins?
    Last edited by timmu; 24th October 2012 at 10:30.

  10. #8
    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
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: compiling for Windows

    Quote Originally Posted by timmu View Post
    I think I could use some help with running this QImageWriter::supportedImageFormats() test. Would you be able to help with more details as to what exactly I should put in my code? Thanks!
    Qt Code:
    1. int main(int argc, char **argv) {
    2. QApplication app(argc, argv);
    3. qDebug() << QImageWritter::supportedImageFormats();
    4. return 0;
    5. }
    To copy to clipboard, switch view to plain text mode 

    In my /plugins/imageformats folder I have libqjpeg.a and libqjpegd.a. Does that mean that I have the plugins?
    Maybe yes, maybe not. They look like image plugins and it looks like you are linking them in your project but maybe you are not creating their instances in your program.

    Try adding a Q_IMPORT_PLUGIN(qjpeg) line in your code.

    This will make my above snippet look like:

    Qt Code:
    1. #include <QtGui>
    2. Q_IMPORT_PLUGIN(qjpeg)
    3.  
    4. int main(int argc, char **argv) {
    5. QApplication app(argc, argv);
    6. qDebug() << QImageWritter::supportedImageFormats();
    7. return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 
    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. The following user says thank you to wysota for this useful post:

    timmu (24th October 2012)

  12. #9
    Join Date
    Aug 2009
    Posts
    122
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    74

    Default Re: compiling for Windows

    Thank you so much, Wysota! You are alays so helpful!

    Indeed I forgot to add Q_IMPORT_PLUGIN(qjpeg)

    All I had to do now was include <QtPlugin> and do "make clean"
    and everything worked like magic!

Similar Threads

  1. compiling id3lib on windows Qt
    By harkon in forum Qt Programming
    Replies: 7
    Last Post: 26th April 2010, 22:15
  2. Compiling from linux to windows
    By walito in forum Qt Programming
    Replies: 1
    Last Post: 28th July 2009, 22:25
  3. Compiling in Windows
    By srohit24 in forum Newbie
    Replies: 4
    Last Post: 14th February 2009, 09:56
  4. Need help with compiling on Windows
    By Cruz in forum Newbie
    Replies: 4
    Last Post: 29th January 2009, 11:09
  5. compiling under windows's troubles
    By giusepped in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2008, 16:27

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.