Results 1 to 20 of 20

Thread: Stupid Windows Compilation Trick

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: Stupid Windows Compilation Trick

    Quote Originally Posted by skepticalgeek View Post
    Well, my development environment is Qt Creator 2.0 for Windows.
    I don't mean Creator. I mean your include files and such.

    As far as my includes, i looked down the chain, and it is mostly Qt classes that are included, and a few other things like cdio.
    If you are using ::write() then it's somethine more than just Qt. Some library is probably screwing up your compilation.

    Any way I can check the include chain to find anything suspicious?
    I doubt it is anything obvious.

    Like I said before, the most frustrating thing is, that this exact code compile fine under Linux using gcc, but fails under Windows using mingw.
    If your Windows files destroy the compilation then I can believe that happening. I've already seen it

    You can do two things. First start getting rid of include files (and code that uses it) until the compilation starts working again - then you'll know which file is the first in chain of causing the problem. The other thing you can do is take the file the compiler complains about, open it on the line it complains about and read carefully everything that is before this line - maybe you will spot something disturbing. Especially pay attention to macros defined and grep your includes for them. It could be that one library relies on a macro being defined and some other library undefines it because of some reason.
    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
    Jan 2010
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Stupid Windows Compilation Trick

    Thanks for the help. I struggled with the issue all weekend, and finally solved it by changing the order of the includes in the header file for the form. It took me a while to find the exact sequence. Any flags I can pass to Qmake or MinGw so that it will be smart enough to figure this out on it's own, without me having to guess at which order it wants the include statements in?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: Stupid Windows Compilation Trick

    Quote Originally Posted by skepticalgeek View Post
    Any flags I can pass to Qmake or MinGw so that it will be smart enough to figure this out on it's own, without me having to guess at which order it wants the include statements in?
    No, it's not possible. Consider the following two include files:
    Qt Code:
    1. // A.h
    2. #ifndef SOME_VAR
    3. #define SOME_VAR 1
    4. #endif
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. // B.h
    2. #ifndef SOME_VAR
    3. #define SOME_VAR 2
    4. #endif
    To copy to clipboard, switch view to plain text mode 
    and then:
    Qt Code:
    1. // main.cpp
    2. #include <A.h>
    3. #include <B.h>
    To copy to clipboard, switch view to plain text mode 
    It's not possible to determine if this is a correct include order or not without knowing the effect you want to achieve. The compiler can't do it for you.
    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.


  4. #4
    Join Date
    Jan 2010
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Stupid Windows Compilation Trick

    Fair enough. Any idea why the original compilation order worked under Linux, and choked under Windows? Same code,same IDE (Qt Creator), same header files for the 3rd party libraries. The only difference is I was linking to 3rd party DLLs in the pro file, instead of 3rd party .so files.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: Stupid Windows Compilation Trick

    Quote Originally Posted by skepticalgeek View Post
    Fair enough. Any idea why the original compilation order worked under Linux, and choked under Windows? Same code,same IDE (Qt Creator), same header files for the 3rd party libraries.
    ... different defines active for each platform in those same files.
    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.


  6. #6
    Join Date
    Jan 2010
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Stupid Windows Compilation Trick

    Well, the multiple definition errors are back again, and this time they mean business. I though everything was working, until I made a minor code change, and kaboom! Here they come back for more. Here is a sample of the output, I ran into the character limit trying o post all of it:

    In function `Z17qVariantFromValueI8QVariantES0_RKT_':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:453: multiple definition of `QVariant qVariantFromValue<QVariant>(QVariant const&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:453: first defined here
    ./debug\moc_frmrip.o: In function `Z16qVariantSetValueI8QVariantEvRS0_RKT_':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:475: multiple definition of `void qVariantSetValue<QVariant>(QVariant&, QVariant const&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:475: first defined here
    ./debug\moc_frmrip.o: In function `QVariant':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:480: multiple definition of `QVariant::QVariant()'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:480: first defined here
    ./debug\moc_frmrip.o: In function `QVariant':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:480: multiple definition of `QVariant::QVariant()'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:480: first defined here
    ./debug\moc_frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:481: multiple definition of `QVariant::isValid() const'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:481: first defined here
    ./debug\moc_frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:536: multiple definition of `QVariant::isDetached() const'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:536: first defined here
    ./debug\moc_frmrip.o: In function `ZeqRK8QVariantRK24QVariantComparisonHelper':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:558: multiple definition of `operator==(QVariant const&, QVariantComparisonHelper const&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:558: first defined here
    ./debug\moc_frmrip.o: In function `ZneRK8QVariantRK24QVariantComparisonHelper':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:563: multiple definition of `operator!=(QVariant const&, QVariantComparisonHelper const&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:563: first defined here
    ./debug\moc_frmrip.o: In function `Z13qvariant_castI8QVariantET_RKS0_':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:583: multiple definition of `QVariant qvariant_cast<QVariant>(QVariant const&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:583: first defined here
    ./debug\moc_frmrip.o: In function `Z11qIsDetachedI8QVariantEbRT_':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:601: multiple definition of `bool qIsDetached<QVariant>(QVariant&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:601: first defined here
    ./debug\moc_frmrip.o: In function `Z5qSwapI8QVariantEvRT_S2_':
    C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:601: multiple definition of `void qSwap<QVariant>(QVariant&, QVariant&)'
    ./debug\frmrip.o:C:\SKG_Jukebox/../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qvariant.h:601: first defined here
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [SKG_Jukebox.exe] Error 1
    mingw32-make: *** [debug] Error 2
    The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project SKG_Jukebox (target: Desktop)
    When executing build step ''

    The problems seem to be coming from my moc object files. It looks like qmake is making defective files, then the compiler is complaining about the multiple definitions. I am not putting this in my code. I am not making up new definitions of basic Qt objects and functions, and then wondering why they don't compile. I checked my pro file 3 times, no duplicate entries in the file list. Here it is though, if it can help anyone figure this out.

    # -------------------------------------------------
    # Project created by QtCreator 2010-01-22T23:16:56
    # -------------------------------------------------
    QT += network \
    phonon \
    xml
    TARGET = SKG_Jukebox
    TEMPLATE = app
    SOURCES += main.cpp \
    SKG_RoundButton/skg_roundbutton.cpp \
    jukeboxconfig.cpp \
    SKG_AlbumPanelSmall/skg_albumpanelsmall.cpp \
    SKG_AlbumPanelSmall/skg_albumpanelframesmall.cpp \
    SKG_AlbumPanel/skg_albumpanel.cpp \
    SKG_AlbumPanel/skg_albumpanelframe.cpp \
    SKG_AlbumWidget/skg_albumwidget.cpp \
    SKG_AlbumWidget/skg_albumframe.cpp \
    lib/skglib.cpp \
    SKG_Button/skg_button.cpp \
    mainnetbook.cpp \
    mainnormal.cpp \
    frmrip.cpp \
    frmtracklist.cpp \
    frmoptions.cpp \
    googleimagesearch.cpp \
    yahooimagesearch.cpp \
    frmalbumart.cpp \
    frmalbumartdialog.cpp \
    frmalbumartmulti.cpp \
    customalbumlist.cpp \
    customlistmanager.cpp \
    frmloadcustomlist.cpp \
    frmconfig.cpp \
    frmaddeditlist.cpp \
    keytranslator.cpp \
    # ogg_encoder.cpp \
    mp3_encoder.cpp \
    # flac_encoder.cpp \
    cd_extractor.cpp \
    frmdialog.cpp \
    playlist.cpp \
    playlistmanager.cpp \
    frmaddeditplaylist.cpp \
    frmloadplaylist.cpp \
    frmsplash.cpp \
    freedblookup.cpp
    HEADERS += SKG_RoundButton/skg_roundbutton.h \
    jukeboxconfig.h \
    SKG_AlbumPanelSmall/skg_albumpanelsmall.h \
    SKG_AlbumPanelSmall/skg_albumpanelframesmall.h \
    SKG_AlbumPanel/skg_albumpanel.h \
    SKG_AlbumPanel/skg_albumpanelframe.h \
    SKG_AlbumWidget/skg_albumwidget.h \
    SKG_AlbumWidget/skg_albumframe.h \
    lib/skglib.h \
    SKG_Button/skg_button.h \
    mainnetbook.h \
    mainnormal.h \
    frmrip.h \
    frmtracklist.h \
    frmoptions.h \
    googleimagesearch.h \
    yahooimagesearch.h \
    frmalbumart.h \
    frmalbumartdialog.h \
    frmalbumartmulti.h \
    customalbumlist.h \
    customlistmanager.h \
    frmloadcustomlist.h \
    frmconfig.h \
    frmaddeditlist.h \
    keytranslator.h \
    # ogg_encoder.h \
    mp3_encoder.h \
    # flac_encoder.h \
    cd_extractor.h \
    frmdialog.h \
    playlist.h \
    playlistmanager.h \
    frmaddeditplaylist.h \
    frmloadplaylist.h \
    frmsplash.h \
    freedblookup.h
    FORMS += mainnetbook.ui \
    mainnormal.ui \
    SKG_AlbumPanelSmall/skg_albumpanelframesmall.ui \
    SKG_AlbumPanel/skg_albumpanelframe.ui \
    SKG_AlbumWidget/skg_albumframe.ui \
    frmtracklist.ui \
    frmoptions.ui \
    frmalbumart.ui \
    frmalbumartdialog.ui \
    frmalbumartmulti.ui \
    frmloadcustomlist.ui \
    frmconfig.ui \
    frmaddeditlist.ui \
    frmrip.ui \
    frmdialog.ui \
    frmaddeditplaylist.ui \
    frmloadplaylist.ui \
    frmsplash.ui

    LIBS += -LC:\Qjson\lib -lqjson0 \
    -LC:\SKG_Jukebox\dll \
    -llibcdio-10 \
    -llibcdio_cdda-0 \
    -llibcdio_paranoia-0 \
    -llame_enc

    At this point, I no longer care why this is occurring. I just want it to stop. I want to know which arguments I can pass to qmake or mingw-make32, to get it to stop creating object files with multiple definitions of standard Qt classes, or to ignore them in the compilation process. I don't feel I should have to play guessing games with the preprocessor, to determine which Qt include files I can and cannot include in my objects. I just want Qt creator, and the tools it is using, to stop prison raping me, and compile what I wrote, in the absence of syntax errors. Again, this exact project compiles and runs like a dream in Linux. What is it about Qt in Windows that it wants to make my life miserable. And it all started when I tried adding this one form. There are over a dozen forms in this project, and it is only this one, FrmRip, that caused all this. Before this, the project compiled and ran fine under Windows. There is nothing in the include chain in this form except Qt headers, and some third party headers that I know are not the problem. I can post the includes here, if that will help anyone. Sorry if I came off a little too angry, but I am tired of wrestling with this, and getting desperate.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: Stupid Windows Compilation Trick

    It's not that simple. There is no "--dont-throw-errors-on-me" compiler switch. Begin with a simple project, start adding files (and code) to it until it stops compiling. Then you'll know where to look for the problem.
    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. #8
    Join Date
    Jan 2010
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Stupid Windows Compilation Trick

    I wasn't looking for a "don't throw errors" switch. I don't object to the compiler throwing errors. I object to it throwing errors on stuff I didn't write. I didn't create multiple definitions of all these Qt objects, qmake or the linker did. I want them to stop doing that. Failing that, I was looking for something like a /FORCE switch in Visual Studio, or something like an ignore multiple definitions switch.

    That said, I appreciate the time you've taken to try to help me on this. I'm just frustrated. As far as I can tell, I haven't done anything but include standard Qt headers in a Qt project, then watched the compiler tell me to screw myself. For some reason, that stops being fun after about a week.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    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: Stupid Windows Compilation Trick

    Quote Originally Posted by skepticalgeek View Post
    I didn't create multiple definitions of all these Qt objects, qmake or the linker did.
    No, they didn't.

    I want them to stop doing that.
    So don't use 3rd party libraries that break your compilation.

    Failing that, I was looking for something like a /FORCE switch in Visual Studio, or something like an ignore multiple definitions switch.
    Sure. Assuming you have the following two definitions of the same method:
    Qt Code:
    1. bool func() { return true; }
    2. bool func() { return false; }
    To copy to clipboard, switch view to plain text mode 
    Which one would you like for the compiler to ignore automatically?

    I'm just frustrated.
    Don't be. Just do what I suggested.

    As far as I can tell, I haven't done anything but include standard Qt headers in a Qt project, then watched the compiler tell me to screw myself. For some reason, that stops being fun after about a week.
    But you can't blame Qt for that. From what I see you are using 3rd party libraries that have their own includes and own functions/classes. You can't call that including only "standard Qt headers in a Qt project". I'm sure that if you remove all those non-Qt includes (and of course code related to them), your application will compile just fine.
    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. Compilation fails in Windows XP
    By sim in forum Newbie
    Replies: 3
    Last Post: 1st July 2010, 16:56
  2. Replies: 4
    Last Post: 19th March 2010, 18:16
  3. Cross compilation from OS X to Windows
    By NicholasSmith in forum Installation and Deployment
    Replies: 3
    Last Post: 15th January 2009, 17:43
  4. QT 4.4.1 compilation problem on Windows using nmake
    By operis in forum Installation and Deployment
    Replies: 1
    Last Post: 1st September 2008, 10:08
  5. Qt compilation windows with g++
    By bonics in forum Qt Programming
    Replies: 2
    Last Post: 14th August 2007, 13:22

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.