Results 1 to 20 of 20

Thread: Stupid Windows Compilation Trick

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

    Default Stupid Windows Compilation Trick

    I am porting my Linux Qt jukebox project to Windows. Everything is working correctly except for the CD Ripper portion. I am having a problem with the portion of the code that extracts the tracks from the CDs. Here is the code in question:

    Qt Code:
    1. void CD_Extractor::Extract(int tracknum)
    2. {
    3. int size;
    4. char *buf;
    5. int16_t *readresult;
    6. long result;
    7. long x;
    8. long firstsector,lastsector;
    9. int i;
    10. QString fname;
    11.  
    12. Paranoia = cdio_paranoia_init(Drive);
    13. firstsector = cdio_cddap_track_firstsector(Drive, tracknum);
    14. lastsector = cdio_cddap_track_lastsector(Drive, tracknum);
    15. size = (lastsector - firstsector) + 1;
    16. SectorsTotal = size;
    17. SectorsRead = 0;
    18. cdio_cddap_speed_set(Drive,32);
    19. paranoia_modeset(Paranoia, PARANOIA_MODE_FULL); //^PARANOIA_MODE_NEVERSKIP);
    20. paranoia_seek(Paranoia, firstsector, SEEK_SET);
    21. QFile file("/home/patrick/SKG_Jukebox/tracks/Track" + QString::number(tracknum) + ".wav");
    22. file.open(QIODevice::WriteOnly);
    23. WriteWav(file.handle(),size * CD_Framesize_Raw);
    24. for (i = firstsector; i <= lastsector; i++)
    25. {
    26. try
    27. {
    28. //readresult = cdio_paranoia_read(Paranoia,NULL);
    29. readresult = cdio_paranoia_read_limited(Paranoia,NULL,3);
    30. SectorsRead++;
    31. buf = (char*)readresult;
    32. file.write(buf,CD_Framesize_Raw);
    33. UpdateProgress(Progress());
    34. QApplication::processEvents();
    35. }
    36. catch(...)
    37. {
    38. break;
    39. }
    40. }
    41. fname = file.fileName();
    42. file.close();
    43. cdio_paranoia_free(Paranoia);
    44.  
    45. ExtractFinished(fname);
    46. }
    47.  
    48. void CD_Extractor::WriteWav(int f,long bytes)
    49. {
    50. /* quick and dirty */
    51.  
    52. write(f,"RIFF",4); /* 0-3 */
    53. PutNum(bytes+44-8,f,0,4); /* 4-7 */
    54. write(f,"WAVEfmt ",8); /* 8-15 */
    55. PutNum(16,f,0,4); /* 16-19 */
    56. PutNum(1,f,0,2); /* 20-21 */
    57. PutNum(2,f,0,2); /* 22-23 */
    58. PutNum(44100,f,0,4); /* 24-27 */
    59. PutNum(44100*2*2,f,0,4); /* 28-31 */
    60. PutNum(4,f,0,2); /* 32-33 */
    61. PutNum(16,f,0,2); /* 34-35 */
    62. write(f,"data",4); /* 36-39 */
    63. PutNum(bytes,f,0,4); /* 40-43 */
    64. }
    65.  
    66. void CD_Extractor::PutNum(long num,int f,int endianness,int bytes){
    67. int i;
    68. unsigned char c;
    69.  
    70. if(!endianness)
    71. i=0;
    72. else
    73. i=bytes-1;
    74. while(bytes--){
    75. c=(num>>(i<<3))&0xff;
    76. if(write(f,&c,1)==-1){
    77. perror("Could not write to output.");
    78. exit(1);
    79. }
    80. if(endianness)
    81. i--;
    82. else
    83. i++;
    84. }
    85. }
    To copy to clipboard, switch view to plain text mode 

    When I try to compile, this is what I get:
    'write' was not declared in this scope

    After digging around, I found that the version of "write" I was using in WriteWav needed the unistd.h header. So I added "#include <unistd.h>" to my source file. That's when things got really interesting. Now when I try to compile, I get this:

    debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagES0_':
    C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/global/qglobal.h:1368: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, QEventLoop::ProcessEventsFlag)'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
    debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagE6QFlagsIS0_E' :
    C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, QFlags<QEventLoop::ProcessEventsFlag>)'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
    debug/cd_extractor.o: In function `ZorN10QEventLoop17ProcessEventsFlagEi':
    C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: multiple definition of `operator|(QEventLoop::ProcessEventsFlag, int)'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qeventloop.h:95: first defined here
    debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215: multiple definition of `QCoreApplication::sendEvent(QObject*, QEvent*)'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215: first defined here
    debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218: multiple definition of `QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*)'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218: first defined here
    debug/cd_extractor.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220: multiple definition of `QCoreApplication::sendPostedEvents()'
    debug/mainwindow.o:C:\SKG_Jukebox\CDRipperTest-build-desktop/../../Qt/2010.04/qt/include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220: first defined here
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [debug\CDRipperTest.exe] Error 1
    mingw32-make: *** [debug] Error 2


    Keep in mind that this exact code compiles and runs just fine under Linux. I'm linked to the correct DLLs. I tried cleaning the project and running QMake. Any insights anyone? This is kind of hlding up my Windows port.
    Last edited by wysota; 30th August 2010 at 17:15.

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

    Default Re: Stupid Windows Compilation Trick

    Update. I can get rid of the second issue by commenting out the include statement for QApplication, but this means I can't use processEvents, which is causing other issues. Hopefully this helps someone narrow it down.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stupid Windows Compilation Trick

    There seems to be multiple definitions of "operator|" as the error says. Look for such instances in the code.

  4. #4
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stupid Windows Compilation Trick

    Hi,

    One rule i follow for windows include order is this :

    Qt Code:
    1. #include "ProjectHeaders.h"
    2. #include <QHeaders>
    3. #include <stdheaders.h>
    To copy to clipboard, switch view to plain text mode 

    wihtout this order i sometimes get ununderstandable compilation errors (this also means: avoid precompiled headers if possible)

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

    Default Re: Stupid Windows Compilation Trick

    Last time I checked Windows was not a Unix system, so I guess it may not have <unistd.h> or ::write().
    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
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Stupid Windows Compilation Trick

    The uninstd.h header is there, I can link to it fine. Like I said, I can compile if I comment out the include statement for QApplication, but then I can't use processEvents, which I need so that the loop is able to send the signal to the calling thread. Without it, the signal UpdateProgress() never gets received. I tried changing the order of the include statements the way totem suggested, and I went from a few compile errors to hundreds. I got multiple definition errors for just about every Qt function on the face of the earth. It's almost like different sections of the code are linking to different versions of Qt, but I only have one on my system, 4.6.3 with Qt Creator 2.0. Thanks for the suggestions. I can post more code or compiler output if that would help.

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

    Default Re: Stupid Windows Compilation Trick

    Please provide a minimal compilable example reproducing 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
    Jul 2010
    Posts
    21
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Stupid Windows Compilation Trick

    Since you are already working with QFiles, why don't you simply use QFile::write() instead of ::write()? QFile is portable.

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

    Default Re: Stupid Windows Compilation Trick

    Hello, I'm back with more of the same. I thought I had these issues resolved by adding some include statements but, like an unwanted guest, it pooed up again. I tried adding a form back into my main project, that I had originally commented out of the pro file until I could figure out how to get the functionality (CD Ripping) to work in Windows. I added the form, but commented out all code relating to extraction and encoding, and am ending up with compile problems again. First, under Build Issues, I get the most useless error message on the face of the earth:

    error: collect2: ld returned 1 exit status

    Seriously, this error message is so unhelpful, it may as well have come from Microsoft. When I look at Compile Output, here is where it seems to be choking:

    ./release\moc_frmrip.o:moc_frmrip.cpp.text+0x0): multiple definition of `void qSwap<QPicture>(QPicture&, QPicture&)'
    ./release\frmrip.o:frmrip.cpp.text+0x0): first defined here
    ./release\moc_frmrip.o:moc_frmrip.cpp.text+0x1f4): multiple definition of `bool qIsDetached<QPicture>(QPicture&)'
    ./release\frmrip.o:frmrip.cpp.text+0xbc0): first defined here
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [release\SKG_Jukebox.exe] Error 1
    mingw32-make: *** [release] 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

    Here is the kicker. I am not defining qSwap or qIsDetached anywhere. I am not using them anywhere. I have not heard of them until they popped up here. I am not even using any QPicture objects in this form. So where the @#$% is the error message coming from?

    On a related note, are there any make arguments I can pass to get Mingw to ignore these multiple definitions? Or anything I can do at all to keep it from being such a massive piece of crap? Sorry about the language, but I am sick and tired of taking code that compiles and executes perfectly fine under Linux, porting it to Windows, and having it immediately become possessed by demons. Thanks in advance for any insights anyone might have here.

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

    Default Re: Stupid Windows Compilation Trick

    You are really doing something weird or you have a screwed up development environment. You are including some file which is including some file which is including... and finally it is including the file causing the problem. I'd say you have some macro conflict which is causing multiple inclusion of some file or you are linking the same code twice. Or you have forgotten to put guardians in your include files to prevent double inclusion in your code.
    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
    Jan 2010
    Posts
    40
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Stupid Windows Compilation Trick

    Well, my development environment is Qt Creator 2.0 for Windows. 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. Any way I can check the include chain to find anything suspicious? 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.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    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?

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    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.

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    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.

  18. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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.


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

    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.

  20. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.