Results 1 to 20 of 20

Thread: Stupid Windows Compilation Trick

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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.